<!DOCTYPE html>
<!-- saved from url=(0038)https://www.jianshu.com/p/c449dec43099 -->
<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, minimum-scale=1.0"><meta http-equiv="X-UA-Compatible" content="ie=edge,chrome=1"><meta http-equiv="Cache-Control" content="no-siteapp"><meta http-equiv="Cache-Control" content="no-transform"><meta name="applicable-device" content="pc,mobile"><meta name="MobileOptimized" content="width"><meta name="HandheldFriendly" content="true"><meta name="theme-color" content="#ec7259"><meta name="renderer" content="webkit"><meta name="force-rendering" content="webkit"><meta name="google" value="notranslate"><meta property="wb:webmaster" content="294ec9de89e7fadb"><meta property="qc:admins" content="104102651453316562112116375"><meta property="qc:admins" content="11635613706305617"><meta property="qc:admins" content="1163561616621163056375"><meta name="360-site-verification" content="604a14b53c6b871206001285921e81d8"><meta name="google-site-verification" content="cV4-qkUJZR6gmFeajx_UyPe47GW9vY6cnCrYtCHYNh4"><meta name="google-site-verification" content="HF7lfF8YEGs1qtCE-kPml8Z469e2RHhGajy6JPVy5XI"><meta name="tencent-site-verification" content="da26ce22cfed7aba6a96d8409f9b53a6"><meta name="apple-mobile-web-app-title" content="简书"><link href="" rel="shortcut icon" type="image/x-icon"><link rel="dns-prefetch" href="https://cdn2.jianshu.io/"><link rel="dns-prefetch" href="https://upload-images.jianshu.io/"><meta http-equiv="mobile-agent" content="format=html5; url=https://www.jianshu.com/p/c449dec43099"><meta name="apple-itunes-app" content="app-id=888237539, app-argument=jianshu://notes/56640005"><meta property="al:ios:url" content="jianshu://notes/56640005"><meta property="al:ios:app_store_id" content="888237539"><meta property="al:ios:app_name" content="简书"><meta property="al:android:url" content="jianshu://notes/56640005"><meta property="al:android:package" content="com.jianshu.haruki"><meta property="al:android:app_name" content="简书"><title>SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书</title><meta name="robots" content="index,follow"><meta name="googlebot" content="index,follow"><meta name="description" content="一、功能目的 SpringBoot 实现Http分片下载断点续传，从而实现H5页面的大视频播放问题，实现渐进式播放，每次只播放需要播放的内容就可以了，不需要加载整个文件到内存..."><meta name="twitter:card" content="summary"><meta name="twitter:site" content="@jianshu.com"><meta property="fb:app_id" content="865829053512461"><meta property="og:url" content="https://www.jianshu.com/p/c449dec43099"><meta property="og:type" content="article"><meta property="og:title" content="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放"><meta property="og:description" content="一、功能目的 SpringBoot 实现Http分片下载断点续传，从而实现H5页面的大视频播放问题，实现渐进式播放，每次只播放需要播放的内容就可以了，不需要加载整个文件到内存..."><meta property="og:image" content="https://upload-images.jianshu.io/upload_images/11736889-3445e784899b338a.png"><meta property="og:site_name" content="简书"><meta name="next-head-count" content="45"><link rel="preload" href="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/[slug].js" as="script"><link rel="preload" href="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/_app.js" as="script"><link rel="preload" href="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/webpack-24455e893ca493bd6438.js" as="script"><link rel="preload" href="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/commons.6f517ba4cf1108d0202d.js" as="script"><link rel="preload" href="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/styles.bc441c9093dbddd27ab9.js" as="script"><link rel="preload" href="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/main-516394b4705a784b7589.js" as="script"><link rel="preload" href="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/commons.d54d167b.chunk.css" as="style"><link rel="stylesheet" href="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/commons.d54d167b.chunk.css"><link rel="preload" href="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/styles.65841447.chunk.css" as="style"><link rel="stylesheet" href="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/styles.65841447.chunk.css"><link rel="stylesheet" type="text/css" href="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/12.b5240dfc.chunk.css"><script src="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/osd.js"></script><script src="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/f(6).txt"></script><script src="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/f(7).txt" id="google_shimpl"></script><script charset="utf-8" src="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/12.fc1b04e5ce692276772d.js"></script><link rel="stylesheet" type="text/css" href="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/13.1563bf97.chunk.css"><script charset="utf-8" src="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/13.a2138ae69ceab0815297.js"></script><script charset="utf-8" src="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/11.75b56346ed2db2849ee4.js"></script><link rel="stylesheet" type="text/css" href="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/10.7bd46f64.chunk.css"><script charset="utf-8" src="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/10.fd5ba254950c4f2f8d87.js"></script><link rel="preload" href="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/f(8).txt" as="script"><script type="text/javascript" src="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/f(8).txt"></script><link rel="preload" href="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/f(9).txt" as="script"><script type="text/javascript" src="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/f(9).txt"></script></head><body class="" style=""><svg class="wCYvWN" style="display:none;width:0;height:0" width="0" height="0" focusable="false" aria-hidden="true"><symbol id="ic-write" viewBox="0 0 1024 1024"><path d="M151.007 942.26766666c-22.993 21.261-64.594 64.683-43.381-35.512 37.218-163.524 447.875-792.517 794.003-852.861 97.053 0-180.459 232.311-180.459 232.311 0 0 95.338 11.846 157.962-54.296-37.533 195.818-214.91 195.149-260.719 210.729 53.59 7.89 93.441 31.594 176.379 7.368-20.222 55.519-100.075 123.839-387.175 191.454-126.92 45.617-233.617 279.547-256.61 300.808z"></path></symbol><symbol id="ic-money" viewBox="0 0 1024 1024"><path d="M884.363636 512C884.363636 306.349242 717.650758 139.636364 512 139.636364 306.349242 139.636364 139.636364 306.349242 139.636364 512 139.636364 717.650758 306.349242 884.363636 512 884.363636 717.650758 884.363636 884.363636 717.650758 884.363636 512ZM46.545455 512C46.545455 254.936553 254.936553 46.545455 512 46.545455 769.063447 46.545455 977.454545 254.936553 977.454545 512 977.454545 769.063447 769.063447 977.454545 512 977.454545 254.936553 977.454545 46.545455 769.063447 46.545455 512ZM470.626262 520.334527 346.368469 520.334527C335.022727 520.334527 325.818182 511.082366 325.818182 499.669243L325.818182 478.939206C325.818182 467.431177 335.018859 458.273923 346.368469 458.273923L459.41918 458.273923 362.752701 343.071299C355.558764 334.497899 356.572921 321.312715 365.315879 313.976502L381.196011 300.65149C390.011671 293.254272 402.96653 294.447111 410.293884 303.179511L512.303444 424.749773 614.313007 303.179511C621.64036 294.447111 634.595221 293.254272 643.410879 300.65149L659.29101 313.976502C668.033969 321.312715 669.048129 334.497899 661.854189 343.071299L565.18771 458.273923 677.63153 458.273923C688.977273 458.273923 698.181818 467.526083 698.181818 478.939206L698.181818 499.669243C698.181818 511.177272 688.981141 520.334527 677.63153 520.334527L553.373738 520.334527 553.373738 582.395136 677.63153 582.395136C688.977273 582.395136 698.181818 591.647297 698.181818 603.060419L698.181818 623.790457C698.181818 635.298486 688.981141 644.455741 677.63153 644.455741L553.373738 644.455741 553.373738 737.562275C553.373738 748.871415 544.025139 758.175739 532.493056 758.175739L491.506944 758.175739C479.797853 758.175739 470.626262 748.946776 470.626262 737.562275L470.626262 644.455741 346.368469 644.455741C335.022727 644.455741 325.818182 635.203579 325.818182 623.790457L325.818182 603.060419C325.818182 591.552391 335.018859 582.395136 346.368469 582.395136L470.626262 582.395136 470.626262 520.334527Z"></path></symbol><symbol id="ic-emoji" viewBox="0 0 1024 1024"><path d="M32 512C32 246.90332 246.90332 32 512 32 777.09668 32 992 246.90332 992 512 992 777.09668 777.09668 992 512 992 246.90332 992 32 777.09668 32 512ZM920 512C920 286.66782219 737.33217875 104 512 104 286.66782219 104 104 286.66782219 104 512 104 737.33217875 286.66782219 920 512 920 737.33217875 920 920 737.33217875 920 512ZM667.59732781 584C661.80988156 664.88360937 594.35802594 728.70452469 512 728.70452469 429.64197219 728.70452469 362.19011938 664.88360937 356.40267313 584 401.27447563 599.63467063 454.6818125 608.70452469 512 608.70452469 569.3181875 608.70452469 622.72552156 599.63467063 667.59732781 584L667.59732781 584ZM368 440C394.50966781 440 416 418.50966781 416 392 416 365.49033219 394.50966781 344 368 344 341.49033219 344 320 365.49033219 320 392 320 418.50966781 341.49033219 440 368 440ZM656 440C682.50966594 440 704 418.50966781 704 392 704 365.49033219 682.50966594 344 656 344 629.49033406 344 608 365.49033219 608 392 608 418.50966781 629.49033406 440 656 440Z"></path></symbol><symbol id="ic-night" viewBox="0 0 1024 1024"><path d="M386.573124 0C340.147815 173.910685 384.73085 366.612567 521.059141 502.940859 657.387432 639.26915 850.089314 683.852184 1024 637.426876 1001.155802 722.908399 956.572765 804.336916 889.51398 871.395701 686.126909 1074.782772 355.991373 1074.782772 152.6043 871.395701-50.782772 668.00863-50.782772 337.87309 152.6043 134.486017 219.663081 67.427236 301.091602 22.8442 386.573124 0Z"></path></symbol><symbol id="ic-mark" viewBox="0 0 1024 1024"><path d="M268.190476 113.777778C214.552381 113.777778 171.154286 155.291291 171.154286 206.03003L170.666667 967.111111 512 828.732735 853.333333 967.111111 853.333333 206.03003C853.333333 155.291291 809.447617 113.777778 755.809525 113.777778L268.190476 113.777778Z"></path></symbol><symbol id="ic-user" viewBox="0 0 1081 1024"><path d="M803.557507 705.46529267C921.627438 734.68811367 1009.013675 841.17086467 1009.013675 968.09948167L1009.013675 999.65574867 113.777778 999.65574867 113.777778 968.09948167C113.777778 845.98765767 194.87339 742.62628167 306.138642 709.26557267 386.042902 689.94662967 446.772745 624.07875167 455.097973 555.06783567 413.092784 526.09210167 380.671395 482.61667367 369.546671 434.01441967L331.247877 266.69273867C301.999138 138.90939267 384.447284 35.55555567 515.334601 35.55555567L604.020878 35.55555567C735.179184 35.55555567 819.313243 139.39951167 792.544825 267.49752267L757.903491 433.27071867C747.227432 484.36012067 713.120956 529.80140967 668.826761 558.82664367 675.211167 624.51970267 729.457687 683.91321067 803.557507 705.46529267Z"></path></symbol><symbol id="ic-setting" viewBox="0 0 1024 1024"><path d="M846.327484 515.083444C846.327484 499.504829 844.9529 484.842604 843.120122 470.180378L939.799171 394.578276C948.504866 387.705358 950.795839 375.334105 945.297505 365.253825L853.658596 206.718508C848.160262 196.638228 835.78901 192.972672 825.708726 196.638228L711.618281 242.457684C687.792168 224.129902 662.133271 209.009481 634.183401 197.554617L616.772011 76.13306C615.397427 65.136391 605.775343 56.888889 594.320475 56.888889L411.042655 56.888889C399.587791 56.888889 389.965705 65.136391 388.591122 76.13306L371.179729 197.554617C343.22986 209.009481 317.570966 224.588096 293.744849 242.457684L179.654404 196.638228C169.11593 192.514478 157.202871 196.638228 151.704536 206.718508L60.065625 365.253825C54.109096 375.334105 56.858263 387.705358 65.56396 394.578276L162.243011 470.180378C160.410233 484.842604 159.035649 499.963024 159.035649 515.083444 159.035649 530.203865 160.410233 545.324285 162.243011 559.986511L65.56396 635.588614C56.858263 642.461531 54.567291 654.832782 60.065625 664.913067L151.704536 823.448383C157.202871 833.528661 169.574124 837.194217 179.654404 833.528661L293.744849 787.709207C317.570966 806.036986 343.22986 821.15741 371.179729 832.612272L388.591131 947.866943C389.965715 958.86361 399.587801 967.111111 411.042665 967.111111L594.320486 967.111111C605.775349 967.111111 615.397439 958.86361 616.772022 947.866943L634.183401 832.612272C662.133271 821.15741 687.792168 805.578792 711.618281 787.709207L825.708726 833.528661C836.247205 837.652412 848.160262 833.528661 853.658596 823.448383L945.297505 664.913067C950.795839 654.832782 948.504866 642.461531 939.799171 635.588614L843.120122 559.986511C844.9529 545.324285 846.327484 530.662059 846.327484 515.083444ZM502.681566 675.45154C414.250017 675.45154 342.313471 603.514994 342.313471 515.083444 342.313471 426.651895 414.250017 354.71535 502.681566 354.71535 591.113114 354.71535 663.04966 426.651895 663.04966 515.083444 663.04966 603.514994 591.113114 675.45154 502.681566 675.45154L502.681566 675.45154Z"></path></symbol><symbol id="ic-wallet" viewBox="0 0 1081 1024"><path d="M78.590372 320.640733C79.612385 263.784132 108.255224 220.849417 161.254046 208.613675L811.774629 58.429164C843.73446 51.050656 875.603143 70.885317 882.986092 102.864395L930.36408 264.731771C930.36408 264.731771 432.674221 267.670638 193.893052 264.731771 191.508185 264.702418 137.002048 273.909722 137.002047 320.464627L888.060649 320.640726C942.735462 320.640726 988.818119 385.402493 988.818119 439.966797L988.818119 835.991046C988.818119 890.695509 928.709194 947.609862 874.118087 947.609862L193.893052 947.609862C139.218237 947.609862 78.590372 890.555352 78.590372 835.991046L78.590372 320.640733ZM870.350433 600.907349C870.350433 562.701243 839.378261 531.729073 801.172156 531.729073 762.96605 531.729073 731.993879 562.701243 731.993879 600.907349 731.993879 639.113461 762.96605 670.085626 801.172156 670.085626 839.378261 670.085626 870.350433 639.113461 870.350433 600.907349Z"></path></symbol><symbol id="ic-like-filled" viewBox="0 0 1024 1024"><path d="M455.286273 907.310814C215.315919 689.706627 56.888889 546.190377 56.888889 370.056797 56.888889 226.540546 169.651657 113.777778 313.167908 113.777778 394.24527 113.777778 472.0609 151.520688 522.850741 211.163805 573.640585 151.520688 651.45621 113.777778 732.533578 113.777778 876.049829 113.777778 988.812595 226.540546 988.812595 370.056797 988.812595 546.190377 830.385567 689.706627 590.415212 907.776774L522.850741 968.817778 455.286273 907.310814Z"></path></symbol><symbol id="ic-feedback" viewBox="0 0 1024 1024"><path d="M158.037561 937.474543C158.037561 937.474543 428.526853 971.883105 479.47676 768.097638L795.921232 768.097638C859.047925 768.097638 910.222222 716.754256 910.222222 654.123816L910.222222 227.7516C910.222222 164.805596 859.18947 113.777778 796.11115 113.777778L227.888848 113.777778C164.867044 113.777778 113.777778 165.12116 113.777778 227.7516L113.777778 654.123816C113.777778 717.069824 164.241867 768.097638 227.072055 768.097638L285.060607 768.097638C254.825383 906.665296 158.037561 937.474543 158.037561 937.474543ZM284.444444 512 625.777778 512 625.777778 597.333333 284.444444 597.333333 284.444444 512 284.444444 512ZM284.473374 312.888889 739.584484 312.888889 739.584484 398.222222 284.473374 398.222222 284.473374 312.888889 284.473374 312.888889Z"></path></symbol><symbol id="ic-signout" viewBox="0 0 1024 1024"><path d="M376.88888867 568.888889L746.66666667 568.888889 632.88888867 682.666667 703.99999967 755.238935 945.77777767 540.444444 945.77777767 483.555556 703.99999967 270.947385 632.88888867 341.333333 746.66666667 455.111111 376.88888867 455.111111 376.88888867 568.888889ZM489.07269967 113.777778L489.07269967 227.888848 206.20427767 227.888848 206.20427767 796.111167 489.07269967 796.111167 489.07269967 910.222222 206.20427967 910.222222C143.37645767 910.222222 92.44444467 859.18947 92.44444467 796.11115L92.44444467 227.888848C92.44444467 164.867044 143.37274867 113.777778 206.20427967 113.777778L489.07269967 113.777778Z"></path></symbol><symbol id="ic-others" viewBox="0 0 1024 1024"><path d="M232.727273 579.87878833C271.28679 579.87878833 302.545455 548.62012233 302.545455 510.06060633 302.545455 471.50108933 271.28679 440.24242433 232.727273 440.24242433 194.167756 440.24242433 162.909091 471.50108933 162.909091 510.06060633 162.909091 548.62012233 194.167756 579.87878833 232.727273 579.87878833ZM512 579.87878833C550.559516 579.87878833 581.818182 548.62012233 581.818182 510.06060633 581.818182 471.50108933 550.559516 440.24242433 512 440.24242433 473.440484 440.24242433 442.181818 471.50108933 442.181818 510.06060633 442.181818 548.62012233 473.440484 579.87878833 512 579.87878833ZM791.272727 579.87878833C829.832243 579.87878833 861.090909 548.62012233 861.090909 510.06060633 861.090909 471.50108933 829.832243 440.24242433 791.272727 440.24242433 752.713211 440.24242433 721.454545 471.50108933 721.454545 510.06060633 721.454545 548.62012233 752.713211 579.87878833 791.272727 579.87878833Z"></path></symbol><symbol id="ic-requests" viewBox="0 0 1024 1024"><path d="M418.909091 372.363636 418.909091 698.181818 605.090909 698.181818 605.090909 372.363636 696.24367 372.363638 511.582813 151.061383 326.921959 372.363638 418.909091 372.363636ZM325.818182 791.272727 325.818182 465.454545 139.636364 465.454545 512 10.219745 884.363636 465.454545 698.181818 465.454545 698.181818 791.272727 325.818182 791.272727ZM791.549193 930.909091C842.809195 930.909091 884.363636 889.589313 884.363636 837.818182L884.363636 744.727273 977.454545 744.727273 977.454545 884.363636C977.454545 961.482668 914.929478 1024 838.088048 1024L185.911951 1024C108.94196 1024 46.545455 961.32575 46.545455 884.363636L46.545455 744.727273 139.636364 744.727273 139.636364 837.818182C139.636364 889.230871 181.271913 930.909091 232.450806 930.909091L791.549193 930.909091Z"></path></symbol><symbol id="ic-follows" viewBox="0 0 1024 1024"><path d="M742.39037 893.84038533C732.980703 903.25005233 718.025272 903.19522133 708.767223 893.93717233L565.458115 753.71907433C556.207048 744.46800633 556.2434 729.40742933 565.554902 720.09592233L605.034543 682.83743133C614.444209 673.42776433 629.399645 673.48259533 638.657694 682.74064433L728.38723 766.49557833 941.491782 540.05939833C950.503205 531.04797933 965.609342 531.03876833 974.920848 540.35027433L1010.521307 576.49106033C1019.930973 585.90072733 1019.963043 600.76926333 1010.812183 609.92012233L742.39037 893.84038533ZM139.636364 859.15151533C139.636364 859.15151533 140.67734 830.50210333 143.721266 818.93653533 149.029303 798.76835333 158.415813 778.50853133 172.872966 759.57276033 185.195819 743.43246833 200.763606 728.89474933 220.104544 716.30744833 248.816792 697.62118933 341.214879 652.42733033 332.078782 657.40617733 390.138425 625.76575033 412.212292 582.79679733 388.559923 518.84814133 384.958515 509.11105133 363.507092 452.78421333 358.209139 437.93037933 342.817466 394.77685333 333.272371 357.97333033 324.783144 304.62989533 312.248334 225.86538933 369.770254 160.96969733 466.26749 160.96969733 571.044971 160.96969733 629.910798 218.91014833 619.986167 306.71758733 613.807085 361.38656133 604.889014 392.41438433 587.2357 428.78513033 587.680116 427.86951433 552.225592 496.14089933 539.29385 524.72497933L624.108763 563.09615833C635.7853 537.28656933 670.418623 470.59648633 670.983024 469.43366333 693.277635 423.50053933 705.13172 382.25771733 712.48809 317.17282433 728.985321 171.21479033 623.998925 67.87878833 466.26749 67.87878833 313.335459 67.87878833 211.18413 183.12496033 232.849136 319.26053733 242.258212 378.38399033 253.244797 420.74554033 270.528472 469.20365633 276.225846 485.17734633 297.956064 542.23624033 301.249676 551.14114433 307.065226 566.86458533 308.380666 564.30394833 287.532892 575.66524233 282.015993 578.67175233 275.594213 581.88642833 265.97112 586.50462633 270.601051 584.28268633 245.145458 596.43114733 238.070951 599.89143433 212.184458 612.55306833 190.997437 624.18127233 169.326586 638.28490833 140.984774 656.73008533 117.593202 678.57391433 98.881863 703.08175233 60.377931 753.51364533 47.027784 804.23828133 46.549412 840.92027533L46.545455 947.98348733 587.235705 947.98345933 512 859.15151533 139.636364 859.15151533Z"></path></symbol><symbol id="ic-chats" viewBox="0 0 1024 1024"><path d="M124.121212 139.636364C88.436364 139.636364 47.010909 181.527273 46.545455 217.212121L46.545455 799.030305C46.545455 842.472727 88.436364 884.363636 124.121212 876.606059L899.878786 876.606059C935.563636 884.363636 977.454545 842.472727 977.454545 799.030305L977.454545 217.212121C977.454545 181.527273 935.563636 139.636364 899.878786 139.636364L124.121212 139.636364ZM512 473.016869 139.636364 232.727273 884.363636 232.727273 512 473.016869ZM139.636364 791.272727 139.636364 331.612007 512 578.515503 884.363636 331.612007 884.363636 791.272727 139.636364 791.272727Z"></path></symbol><symbol id="ic-comments" viewBox="0 0 1024 1024"><path d="M977.454545 164.91403167C977.454545 113.60050467 935.731963 71.75757567 884.264546 71.75757567L139.735452 71.75757567C88.181004 71.75757567 46.545455 113.46514167 46.545455 164.91403167L46.545455 676.78293967C46.545455 728.09646367 88.22568 769.93939367 139.640844 769.93939367L186.181818 769.93939367 186.181818 956.12121167 512 769.93939367 884.524167 769.93939367C935.858506 769.93939367 977.454545 728.23182767 977.454545 676.78293967L977.454545 164.91403167ZM884.363636 164.84848467L884.363636 676.84848467 502.393986 676.84848467 279.272727 769.93939367 279.272727 676.84848467 139.636364 676.84848467 139.636364 164.84848467 884.363636 164.84848467Z"></path></symbol><symbol id="ic-likes" viewBox="0 0 1024 1024"><path d="M511.646501 852.318427C513.3925 850.741015 516.884503 847.586202 516.884503 847.586202 738.668074 646.043071 808.239081 574.380446 853.64177 489.88787 874.584837 450.913673 884.363636 415.390578 884.363636 379.345455 884.363636 287.398144 813.401856 216.436364 721.454545 216.436364 669.217853 216.436364 616.89613 241.028421 582.874945 280.979901L512 364.209197 441.125053 280.979901C407.103871 241.028421 354.782148 216.436364 302.545455 216.436364 210.598144 216.436364 139.636364 287.398144 139.636364 379.345455 139.636364 415.547805 149.501383 451.227391 170.635978 490.39044 216.182926 574.790321 286.220326 646.813794 507.042118 847.054141 507.042118 847.054141 490.96233 871.005342 511.646501 852.318427ZM512 220.625455 578.083025 164.351628C620.609936 138.33686 670.384463 123.345455 721.454545 123.345455 864.814545 123.345455 977.454545 235.985455 977.454545 379.345455 977.454545 555.287273 819.2 698.647273 579.490909 916.48L512 977.454545 444.509091 916.014545C204.8 698.647273 46.545455 555.287273 46.545455 379.345455 46.545455 235.985455 159.185455 123.345455 302.545455 123.345455 353.615536 123.345455 403.390064 138.33686 445.916975 164.351628L512 220.625455Z"></path></symbol><symbol id="ic-spinner" viewBox="0 0 1024 1024"><path d="M300.571429 817.90476233q0 30.285714-21.428572 51.714285T227.428571 891.04761933q-29.714286 0-51.428571-21.714286t-21.714286-51.428571q0-30.285714 21.428572-51.714286T227.428571 744.76190433t51.714286 21.428572T300.571429 817.90476233z m284.571428 117.714285q0 30.285714-21.428571 51.714286T512 1008.76190433t-51.714286-21.428571T438.857143 935.61904733t21.428571-51.714285T512 862.47619033t51.714286 21.428572 21.428571 51.714285zM182.857143 533.33333333q0 30.285714-21.428572 51.714286T109.714286 606.47619033t-51.714286-21.428571T36.571429 533.33333333t21.428571-51.714286T109.714286 460.19047633t51.714285 21.428571T182.857143 533.33333333z m686.857143 284.571429q0 29.714286-21.714286 51.428571t-51.428571 21.714286q-30.285714 0-51.714286-21.428572T723.428571 817.90476233t21.428572-51.714286 51.714286-21.428572 51.714285 21.428572 21.428572 51.714286zM318.857143 248.76190433q0 37.714286-26.857143 64.571429t-64.571429 26.857143-64.571428-26.857143-26.857143-64.571429 26.857143-64.571428 64.571428-26.857143 64.571429 26.857143 26.857143 64.571428z m668.571428 284.571429q0 30.285714-21.428571 51.714286T914.285714 606.47619033t-51.714285-21.428571T841.142857 533.33333333t21.428572-51.714286T914.285714 460.19047633t51.714286 21.428571T987.428571 533.33333333z m-365.714285-402.285714q0 45.714286-32 77.714285t-77.714286 32-77.714286-32-32-77.714285 32-77.714286T512 21.33333333t77.714286 32 32 77.714286z m302.857143 117.714285q0 53.142857-37.714286 90.571429T796.571429 376.76190433q-53.142857 0-90.571429-37.428571T668.571429 248.76190433q0-52.571429 37.428571-90.285714t90.571429-37.714286q52.571429 0 90.285714 37.714286t37.714286 90.285714z"></path></symbol><symbol id="ic-nav-discover" viewBox="0 0 1024 1024"><path d="M13.3565216 512C13.3565216 236.60633067 236.60633067 13.3565216 512 13.3565216S1010.6434784 236.60633067 1010.6434784 512 787.39366933 1010.6434784 512 1010.6434784 13.3565216 787.39366933 13.3565216 512z m926.05217387 0a427.40869547 427.40869547 0 1 0-854.81739094 0 427.40869547 427.40869547 0 0 0 854.81739094 0z m-321.3638496-253.548336c120.29180267-82.53736853 173.6704-39.4165792 119.4369856 95.9295072l-104.9525792 261.6691008-217.9784352 148.8332064c-120.434272 82.1574496-175.90242347 37.70694507-124.13848107-98.6364288l93.93493333-247.42214507 233.65008747-160.37324053zM512 583.23478293a71.23478293 71.23478293 0 1 0 0-142.46956586 71.23478293 71.23478293 0 0 0 0 142.46956586z"></path></symbol><symbol id="ic-nav-notification" viewBox="0 0 1024 1024"><path d="M513.024 1001.828174A111.88313 111.88313 0 0 0 625.39687 890.434783H400.695652a111.88313 111.88313 0 0 0 112.328348 111.393391z m-320.823652-489.293913v5.030956c0 43.408696-13.445565 84.591304-36.062609 122.301218-8.013913 13.312-16.562087 25.154783-25.065739 35.350261-4.897391 5.921391-8.592696 9.794783-10.329043 11.486608l-3.250087 3.650783C57.433043 768.934957 96.478609 845.913043 196.118261 845.913043h634.434782c99.906783 0 135.43513-75.063652 74.306783-153.11026l-1.736348-2.181566-2.048-1.869913a180.535652 180.535652 0 0 1-11.53113-11.976347 298.206609 298.206609 0 0 1-27.603478-36.151653c-24.709565-38.021565-39.357217-79.070609-39.357218-121.366261 0-2.31513 0-4.630261 0.089044-6.945391l-0.044522-76.755478c0-132.096-84.591304-258.626783-189.350957-283.202783C624.951652 91.447652 571.65913 44.521739 507.458783 44.521739 437.426087 44.521739 395.931826 92.16 382.085565 151.863652 268.332522 200.214261 192.333913 310.761739 192.333913 435.556174v63.933217c-0.133565 3.116522-0.133565 6.233043-0.089043 13.089392z m65.80313-72.525913c0-105.427478 67.31687-198.210783 166.199652-232.848696l21.99374-7.657739v-29.028174c0-33.124174 27.38087-60.237913 61.261913-60.237913 33.836522 0 61.217391 27.113739 61.217391 60.237913v29.028174l21.993739 7.702261C689.508174 241.797565 756.869565 334.625391 756.869565 440.05287l0.089044 77.06713-0.089044 7.568696c0 56.765217 18.788174 109.968696 49.775305 158.230261 18.432 28.672 36.953043 49.597217 49.997913 61.618086l-3.739826-4.096c28.093217 36.285217 22.216348 48.88487-22.394435 48.88487H196.118261c-45.456696 0-53.426087-15.894261-26.178783-52.001391l-3.250087 3.695304c12.02087-11.798261 29.072696-32.411826 45.946435-60.816696 28.226783-47.549217 45.278609-100.396522 45.278609-157.250782v-5.431652l0.044522-11.842783V440.008348z"></path></symbol><symbol id="ic-nav-follow" viewBox="0 0 1024 1024"><path d="M725.25913 780.14701467L721.474783 780.05797067H868.173913c24.620522 0 44.521739-19.945739 44.521739-44.744347V134.71536267A44.521739 44.521739 0 0 0 868.08487 89.97101467H155.91513C131.33913 89.97101467 111.304348 110.00579667 111.304348 134.71536267v600.598261A44.432696 44.432696 0 0 0 155.737043 780.05797067h146.832696l-3.784348 0.089044c69.053217-3.873391 154.757565 43.186087 213.036522 106.184348 51.778783-60.594087 125.373217-111.170783 213.437217-106.184348zM44.521739 735.31362367V134.71536267A111.482435 111.482435 0 0 1 155.91513 23.18840567h712.16974A111.304348 111.304348 0 0 1 979.478261 134.71536267v600.598261a111.34887 111.34887 0 0 1-111.304348 111.526956h-146.69913c-66.960696-3.784348-172.78887 74.885565-201.861566 145.67513-4.541217 11.130435-10.685217 10.596174-15.449043-0.756869-29.606957-70.611478-134.90087-148.702609-201.594435-144.918261H155.737043A111.215304 111.215304 0 0 1 44.521739 735.31362367zM489.73913 179.01449267h44.52174V735.53623167h-44.52174V179.01449267z m333.913044 178.086957V290.31884067H623.304348v66.782609h200.347826zM623.304348 512.92753667h200.347826v-66.782609H623.304348V512.92753667zM200.347826 357.10144967H400.695652V290.31884067H200.347826v66.782609z m0 155.826087H400.695652v-66.782609H200.347826V512.92753667z"></path></symbol><symbol id="ic-nav-download" viewBox="0 0 1024 1024"><path d="M222.608696 133.342609C222.608696 84.279652 262.41113 44.521739 311.785739 44.521739h400.428522C761.455304 44.521739 801.391304 84.680348 801.391304 133.342609v757.314782A88.909913 88.909913 0 0 1 712.214261 979.478261H311.785739A89.266087 89.266087 0 0 1 222.608696 890.657391V133.342609zM445.217391 912.695652c0-12.288 9.616696-22.26087 22.038261-22.260869h89.488696c12.154435 0 22.038261 10.329043 22.038261 22.260869 0 12.288-9.616696 22.26087-22.038261 22.26087h-89.488696a22.394435 22.394435 0 0 1-22.038261-22.26087zM289.391304 845.913043h445.217392V111.304348h-445.217392V845.913043zM356.173913 489.73913l155.826087 184.141913L667.826087 489.73913h-89.043478V356.173913h-133.565218v133.565217H356.173913z"></path></symbol><symbol id="ic-nav-mode" viewBox="0 0 1024 1024"><path d="M194.56 597.333333l-64.853333 166.4c-2.858667 9.088-3.413333 15.786667-1.706667 20.053334 1.706667 4.266667 10.24 6.954667 25.6 8.106666l56.32 4.266667v24.746667a521.557333 521.557333 0 0 0-34.56-1.28c-17.365333-0.298667-40.832-0.426667-70.4-0.426667s-53.034667 0.128-70.4 0.426667c-17.365333 0.298667-28.885333 0.725333-34.56 1.28v-24.746667l53.76-4.266667c18.773333-1.706667 31.872-12.245333 39.253333-31.573333L292.693333 256h41.813334l188.586666 498.346667c3.968 9.685333 7.68 16.213333 11.093334 19.626666 3.413333 3.413333 9.685333 6.528 18.773333 9.386667l46.933333 14.506667v23.893333a1946.538667 1946.538667 0 0 0-99.84-2.56h-71.68c-45.525333 0-82.773333 0.853333-111.786666 2.56v-23.893333l53.76-8.533334c16.512-2.858667 25.898667-6.272 28.16-10.24 2.261333-3.968 1.152-11.648-3.413334-23.04L336.213333 597.333333H194.56z m127.146667-39.253333L271.36 398.506667l-61.44 159.573333h111.786667z m427.52 273.92c-23.338667 0-43.392-4.138667-60.16-12.373333a110.805333 110.805333 0 0 1-40.96-33.706667 146.816 146.816 0 0 1-23.466667-50.346667c-5.12-19.328-7.68-40.106667-7.68-62.293333 0-30.165333 4.565333-56.874667 13.653333-80.213333 9.088-23.338667 21.333333-42.965333 36.693334-58.88a153.6 153.6 0 0 1 53.76-36.266667 171.946667 171.946667 0 0 1 64.853333-12.373333c15.914667 0 29.866667 1.152 41.813333 3.413333 11.946667 2.261333 21.888 4.821333 29.866667 7.68 9.685333 2.858667 17.621333 6.272 23.893333 10.24l56.32-31.573333 7.68 2.56v262.826666c0 22.741333 9.685333 33.578667 29.013334 32.426667 4.565333 0 8.106667-0.725333 10.666666-2.133333s4.992-2.688 7.253334-3.84c2.261333-1.706667 4.266667-3.413333 5.973333-5.12l5.12 11.946666c-4.565333 10.794667-10.538667 20.48-17.92 29.013334-6.272 7.381333-14.634667 14.08-25.173333 20.053333-10.538667 5.973333-23.466667 8.96-38.826667 8.96-25.045333 0-42.794667-7.552-53.333333-22.613333-10.538667-15.061333-15.786667-33.408-15.786667-55.04v-20.48a181.888 181.888 0 0 1-12.373333 36.266666 129.92 129.92 0 0 1-20.053334 31.146667 92.373333 92.373333 0 0 1-29.44 22.186667 93.44 93.44 0 0 1-41.386666 8.533333z m103.253333-196.266667c0-11.946667-0.554667-24.448-1.706667-37.546666a143.872 143.872 0 0 0-7.68-36.266667 66.858667 66.858667 0 0 0-18.346666-27.733333c-8.234667-7.381333-19.498667-11.093333-33.706667-11.093334-7.978667 0-16.341333 2.133333-25.173333 6.4-8.832 4.266667-16.938667 11.221333-24.32 20.906667-7.381333 9.685333-13.525333 22.912-18.346667 39.68-4.821333 16.768-7.253333 37.418667-7.253333 61.866667 0 17.066667 1.28 33.28 3.84 48.64 2.56 15.36 6.698667 28.714667 12.373333 40.106666 5.674667 11.392 12.672 20.352 20.906667 26.88 8.234667 6.528 18.048 9.813333 29.44 9.813334 11.392 0 21.333333-3.712 29.866666-11.093334 8.533333-7.381333 15.786667-17.194667 21.76-29.44 5.973333-12.245333 10.538667-26.325333 13.653334-42.24 3.114667-15.914667 4.693333-32.426667 4.693333-49.493333v-9.386667z"></path></symbol><symbol id="ic-alipay" viewBox="0 0 1024 1024"><path d="M1023.795 853.64v6.348a163.807 163.807 0 0 1-163.807 163.807h-696.18A163.807 163.807 0 0 1 0 859.988v-696.18A163.807 163.807 0 0 1 163.807 0h696.181a163.807 163.807 0 0 1 163.807 163.807V853.64z" fill="#009FE9"></path><path d="M844.836 648.267c-40.952-14.333-95.623-34.809-156.846-57.128a949.058 949.058 0 0 0 90.094-222.573H573.325V307.14h245.711v-43.41l-245.71 2.458V143.33H472.173c-18.223 0-21.704 20.476-21.704 20.476v102.38H204.759v40.952h245.71v61.427H245.712v40.952h409.518a805.522 805.522 0 0 1-64.909 148.246c-128.384-42.795-266.186-77.604-354.233-55.08a213.564 213.564 0 0 0-112.003 63.27c-95.418 116.917-26.21 294.034 175.274 294.034 119.989 0 236.087-67.366 325.771-177.73 134.322 65.932 398.666 176.297 398.666 176.297V701.3s-32.352-4.095-178.96-53.033z m-563.702 144.97c-158.893 0-204.759-124.699-126.336-194.112a191.86 191.86 0 0 1 90.913-46.276c93.575-10.238 189.811 35.629 293.624 86.614-74.941 94.598-166.674 153.774-258.2 153.774z" fill="#FFFFFF"></path></symbol><symbol id="ic-diamond" viewBox="0 0 1026 1024"><path d="M751.144277 307.2l-123.016533-238.933333h159.778133a81.92 81.92 0 0 1 59.1872 25.258666l160.256 167.492267A27.306667 27.306667 0 0 1 987.620011 307.2h-236.475734z m270.506667 111.547733L640.927744 946.039467a27.306667 27.306667 0 0 1-48.128-24.234667L766.504277 375.466667h-56.388266l-170.5984 590.165333a27.306667 27.306667 0 0 1-52.462934 0.034133L315.500544 375.466667H259.112277l174.523734 545.5872a27.306667 27.306667 0 0 1-48.128 24.302933L5.160277 418.747733A27.306667 27.306667 0 0 1 27.346944 375.466667H999.464277a27.306667 27.306667 0 0 1 22.152534 43.281066zM18.301611 261.0176L178.557611 93.525333A81.92 81.92 0 0 1 237.744811 68.266667h159.744L274.506411 307.2H38.030677a27.306667 27.306667 0 0 1-19.729066-46.1824zM453.877077 68.266667h117.896534l122.9824 238.933333H330.894677l122.9824-238.933333z"></path></symbol><symbol id="ic-wechat-pay" viewBox="0 0 1076 1024"><path d="M410.493712 644.226288c-64.448471 36.97706-74.006881-20.759958-74.006881-20.759958l-80.772173-193.983933c-31.078562-92.178305 26.897497-41.56191 26.897498-41.561909s49.746372 38.732181 87.50193 62.333712c37.732946 23.602608 80.745253 6.927882 80.745254 6.927882l528.043743-250.842313C881.479874 81.578667 720.547129 0 538.352656 0 241.013636 0 0 217.098768 0 484.919453c0 154.046856 79.806318 291.154103 204.11518 380.019214L181.698086 997.56551s-10.92805 38.720336 26.945952 20.759958c25.808892-12.243853 91.603314-56.122953 130.768353-82.82771 61.570288 22.083298 128.651441 34.345455 198.970414 34.345455 297.315331 0 538.378498-217.098768 538.378499-484.924837 0-77.573115-20.313102-150.8338-56.295235-215.861568-168.236416 104.176656-559.545472 346.282128-609.973434 375.167327z" fill="#00cc22"></path></symbol><symbol id="ic-paid" viewBox="0 0 1024 1024"><path d="M511.850132 0C229.23293 0 0.000088 229.132871 0.000088 511.850044s229.132871 511.850044 511.850044 511.850044 511.850044-229.232842 511.850044-511.850044-229.132871-511.850044-511.850044-511.850044z m226.833545 576.031241c29.191448 0 52.984477 23.693059 52.984477 52.884506 0 14.195841-5.398418 27.491946-15.195548 37.289076-9.997071 9.997071-23.293176 15.39549-37.588988 15.395489H564.034843v173.649127c0 29.091477-23.593088 52.584594-52.484623 52.584594-29.091477 0-52.884506-23.693059-52.984478-52.684565V681.800254H285.016587c-29.191448 0-52.884506-23.693059-52.884507-52.884507s23.693059-52.884506 52.884507-52.884506h173.449185V454.766768H284.816646c-29.191448 0-52.884506-23.593088-52.884507-52.584595s23.693059-52.584594 52.884507-52.584594H474.161173L330.703202 205.939666c-10.097042-9.997071-15.595431-23.193205-15.595431-37.289075 0-14.09587 5.498389-27.491946 15.595431-37.489017 9.997071-9.997071 23.093234-15.39549 37.189105-15.39549 14.09587 0 27.292004 5.498389 37.289075 15.595431l116.46588 116.465879L637.813229 131.261544c9.997071-10.097042 23.193205-15.595431 37.389046-15.595431 14.09587 0 27.192034 5.498389 37.189104 15.39549 20.493996 20.593967 20.593967 54.184126 0 74.678122L569.23332 349.597579h169.350386c29.191448 0 52.984477 23.593088 52.984477 52.584594 0 27.591916-21.493703 50.285268-48.685736 52.484624h-178.947574V576.131212h174.748804v-0.099971z"></path></symbol><symbol id="ic-dislike" viewBox="0 0 1137 1024"><path d="M771.413333 668.728889c-18.773333 3.015111-25.031111 20.878222-28.16 29.866667v217.884444c0 59.733333-49.948444 107.52-112.412444 107.52a115.427556 115.427556 0 0 1-112.412445-92.558222c-31.857778-190.919111-146.830222-263.850667-230.627555-290.133334a27.420444 27.420444 0 0 1-19.228445-26.168888V37.944889C268.572444 17.066667 285.582222 0 306.631111 0h567.864889c59.335111 11.946667 99.953778 32.824889 128 89.543111l128.113778 429.909333c24.974222 77.653333-15.644444 152.291556-106.211556 149.276445H771.413333z m-605.866666-32.824889H81.180444C37.546667 635.904 0 600.064 0 558.250667V80.611556C0 35.84 34.360889 0 81.180444 0H165.546667c29.297778 0 53.077333 23.779556 53.077333 53.077333v529.749334a53.077333 53.077333 0 0 1-53.077333 53.077333z"></path></symbol><symbol id="ic-close" viewBox="0 0 1024 1024"><path d="M511.99967832 371.66626953L792.60221182 91.06373692a99.19122714 99.19122714 0 0 1 140.33340878 140.33340878L652.33308711 511.99967832l280.60253349 280.6025335a99.19122714 99.19122714 0 1 1-140.33340878 140.33340878L511.99967832 652.33308711l-280.60253262 280.60253349a99.19122714 99.19122714 0 1 1-140.33340878-140.33340878L371.66626953 511.99967832 91.06373692 231.3971457A99.19122714 99.19122714 0 1 1 231.3971457 91.06373692L511.99967832 371.66626953z"></path></symbol><symbol id="ic-right" viewBox="0 0 1024 1024"><path d="M570.461091 506.693818L241.384727 177.524364A93.090909 93.090909 0 1 1 373.015273 45.893818L768 440.878545a93.090909 93.090909 0 0 1 0 131.630546l-394.984727 394.891636A93.090909 93.090909 0 0 1 241.384727 835.770182l329.076364-329.076364z"></path></symbol><symbol id="ic-more" viewBox="0 0 4096 1024"><path d="M3495.04988446 991.9952a481.91759063 481.91759063 0 0 1-483.83758031-479.9976c0-265.19867437 216.71891625-479.9976 483.83758031-479.9976S3978.64746665 246.79892562 3978.64746665 511.9976c0 264.95867531-216.47891719 479.9976-483.59758219 479.9976M2065.61703196 991.9952a481.91759063 481.91759063 0 0 1-483.35758312-479.9976c0-265.19867437 216.47891719-479.9976 483.35758312-479.9976 267.11866406 0 483.59758219 214.79892563 483.59758219 479.9976 0 264.95867531-216.47891719 479.9976-483.59758219 479.9976M622.26424884 991.9952A481.91759063 481.91759063 0 0 1 138.66666665 511.9976C138.66666665 246.79892562 355.14558384 32 622.26424884 32S1105.86183102 246.79892562 1105.86183102 511.9976c0 264.95867531-216.47891719 479.9976-483.59758218 479.9976"></path></symbol><symbol id="ic-toggle" viewBox="0 0 1024 1024"><path d="M350.366755 1023.926863a50.025855 50.025855 0 0 0 50.025855-50.025855V174.803795a73.137215 73.137215 0 0 0-124.47954-52.146834L36.096141 359.109577a50.830365 50.830365 0 0 0-0.731372 71.674471 50.537816 50.537816 0 0 0 71.601334 0.877647l193.301659-189.425388v731.737838c0 27.645867 22.453125 50.025855 50.025855 50.025855z"></path><path d="M720.953024 0.005851a47.246641 47.246641 0 0 0-47.246641 47.246641v799.389761a73.137215 73.137215 0 0 0 124.9915 51.634874l190.522446-191.619503a51.415462 51.415462 0 0 0 1.31647-71.089374 45.783897 45.783897 0 0 0-67.066827-0.292548l-155.343445 165.802066V47.252492A47.246641 47.246641 0 0 0 720.953024 0.005851z"></path></symbol><symbol id="ic-notebook" viewBox="0 0 1024 1024"><path d="M178.390055 120.591045C111.268624 120.591045 56.888889 174.401955 56.888889 240.556383V903.97778C56.888889 970.302855 111.097977 1024 178.390055 1024h545.731364c67.121431 0 121.558049-53.81091 121.558049-120.02222V240.613265c0-66.268192-54.209088-120.02222-121.558049-120.02222H178.390055z m455.117432 301.136319H269.06087a30.147761 30.147761 0 0 1 0-60.238641h364.503499a30.147761 30.147761 0 0 1 0 60.238641z m303.18409 301.136318a30.318409 30.318409 0 0 1-30.375291-30.318409V180.317742c0-66.268192-53.81091-120.02222-121.330519-120.022219H329.697688a30.147761 30.147761 0 0 1 0-60.23864l454.946784 0.056882C885.326618 0.113765 967.009987 80.887013 967.009987 180.602155v511.943118a30.318409 30.318409 0 0 1-30.31841 30.318409z m-303.18409-120.47728H269.06087a30.147761 30.147761 0 1 1 0-60.238641h364.503499a30.147761 30.147761 0 0 1 0 60.238641z"></path></symbol><symbol id="ic-check" viewBox="0 0 1433 1024"><path d="M586.88355555 719.072L1197.82755555 108.128a96 96 0 0 1 135.744 135.744L654.75555555 922.688a96 96 0 0 1-135.744 0L111.68355555 515.456A96 96 0 0 1 247.42755555 379.52l339.456 339.456z"></path></symbol><symbol id="ic-plus" viewBox="0 0 1024 1024"><path d="M437.00000029 437.00000029V136.99999971a74.99999971 74.99999971 0 1 1 149.99999942 0v300.00000058h300.00000058a74.99999971 74.99999971 0 0 1 0 149.99999942H586.99999971v300.00000058a74.99999971 74.99999971 0 0 1-149.99999942 0V586.99999971H136.99999971a74.99999971 74.99999971 0 1 1 0-149.99999942h300.00000058z"></path></symbol><symbol id="ic-pencil" viewBox="0 0 1092 1024"><path d="M597.469867 198.724267L81.92 718.574933 0 1024l309.4528-74.410667 512-521.762133-223.982933-229.102933z m400.861866-37.888L858.5216 17.885867a58.845867 58.845867 0 0 0-84.309333 0L657.2032 137.6256l223.914667 229.1712 117.1456-119.808a61.576533 61.576533 0 0 0 0-86.152533h0.068266zM546.133333 930.884267h546.133334V1024H546.133333v-93.115733z m273.066667-186.1632h273.066667v93.115733h-273.066667v-93.115733z"></path></symbol><symbol id="ic-sugar" viewBox="0 0 1024 1024"><path d="M562.362182 689.338182L352.581818 422.632727a182.737455 182.737455 0 0 1 109.056-85.876363l209.780364 266.612363a182.737455 182.737455 0 0 1-109.056 85.876364z m-28.811637 5.725091a183.296 183.296 0 0 1-193.349818-245.76l193.349818 245.76z m150.248728-118.225455l-193.349818-245.76a183.249455 183.249455 0 0 1 193.349818 245.76zM558.545455 282.065455l-40.215273-150.109091 151.738182-40.680728-13.544728-50.548363-202.333091 54.178909L503.156364 277.550545a235.659636 235.659636 0 0 0-199.493819 345.553455L120.925091 672.069818l13.544727 50.548364 200.704-53.76A236.683636 236.683636 0 0 0 465.454545 744.075636l40.215273 150.155637-151.738182 40.634182 13.544728 50.594909 202.333091-54.225455-48.965819-182.690909a235.613091 235.613091 0 0 0 199.493819-345.553455l182.690909-48.919272-13.544728-50.594909-200.704 53.76A236.683636 236.683636 0 0 0 558.545455 282.065455z m126.882909-32.256l126.464-33.885091-13.544728-50.594909-101.189818 27.136-27.089454-101.189819-50.594909 13.544728 40.680727 151.738181 25.274182-6.74909zM338.618182 776.378182l-126.464 33.885091 13.544727 50.548363 101.189818-27.089454 27.089455 101.143273 50.594909-13.498182-40.680727-151.738182-25.274182 6.749091z m-153.6-67.304727l-50.548364 13.544727 40.680727 151.738182 50.548364-13.498182-40.634182-151.738182z m653.963636-392.052364l50.548364-13.544727-40.680727-151.738182-50.548364 13.544727 40.634182 151.738182z"></path></symbol><symbol id="ic-like" viewBox="0 0 1084 1024"><path d="M728.064 343.943529c-17.648941-2.891294-23.552-20.239059-26.503529-28.912941V104.026353C701.560471 46.200471 654.396235 0 595.425882 0c-53.007059 0-97.28 40.478118-106.134588 89.569882-29.997176 184.862118-138.541176 255.457882-217.630118 280.937412a26.142118 26.142118 0 0 0-18.130823 24.877177v560.067764c0 19.817412 16.022588 35.84 35.84 35.84h535.973647c56.018824-11.565176 94.328471-31.804235 120.892235-86.738823l120.832-416.105412c23.552-75.173647-14.757647-147.395765-100.231529-144.564706h-238.772706z m-571.813647 31.744H76.619294C35.358118 375.687529 0 410.383059 0 450.861176v462.426353c0 43.369412 32.406588 78.004706 76.619294 78.004706h79.631059c27.708235 0 50.115765-22.407529 50.115765-50.115764V425.863529a50.115765 50.115765 0 0 0-50.115765-50.115764z"></path></symbol><symbol id="ic-reply" viewBox="0 0 1092 1024"><path d="M173.24799969 781.568C95.168 781.568 32 723.07200031 32 650.94399969V162.56C32 90.49599969 95.04000031 32 172.99200031 32h742.01599969C992.96 32 1056.00000031 90.49599969 1056.00000031 162.62400031v488.31999938c0 72.06400031-63.36 130.62400031-141.12 130.62400031h-343.68l-287.55200062 196.224a12.79999969 12.79999969 0 0 1-19.968-10.87999969l5.63200031-185.34400031H173.24799969z"></path></symbol><symbol id="ic-shang" viewBox="0 0 1024 1024"><path d="M827.512471 177.88486233c35.056941 0 61.982118 8.914824 79.028705 26.684236 17.950118 17.769412 26.985412 44.453647 26.985412 80.052706 0 17.769412-3.614118 43.610353-10.842353 77.402353-3.553882 17.769412-14.336 65.776941-50.236235 65.776941a48.549647 48.549647 0 0 1-35.056941-15.058824 39.273412 39.273412 0 0 1-3.614118-48.971294c9.938824-30.238118 15.299765-56.922353 15.299765-77.402353 0-26.684235-7.228235-26.684235-13.492706-26.684235H189.861647c-0.843294 0-1.807059 0-3.553882 1.807059-1.807059 1.807059-1.807059 2.650353-1.807059 4.457411v108.483765c0 17.829647-11.685647 39.152941-43.971765 39.152941-31.442824 0-43.128471-21.323294-43.12847-39.152941v-110.230588c0-29.394824 8.071529-50.718118 25.118117-65.837177 16.203294-14.275765 38.610824-21.383529 70.053647-21.383529h54.814118a267.685647 267.685647 0 0 0-27.828706-33.731765c-19.757176-22.287059-14.396235-40.96-9.878588-50.778353 8.071529-15.058824 21.504-23.973647 36.743529-23.973647a43.369412 43.369412 0 0 1 30.59953 13.312c3.614118 3.614118 8.071529 8.914824 13.43247 16.022589 5.421176 7.107765 11.685647 16.022588 18.913883 26.684235 11.625412 17.769412 22.407529 35.538824 32.286117 53.36847h128.421647V75.60533333c0-17.769412 10.842353-39.152941 43.128471-39.152941 32.346353 0 43.971765 21.383529 43.971765 39.152941v102.279529h136.553411c7.168-10.661647 15.239529-21.323294 22.467765-32.88847 9.818353-15.119059 19.696941-32.045176 29.635765-48.971294a45.537882 45.537882 0 0 1 22.407529-23.973647 40.357647 40.357647 0 0 1 30.539294-0.90353c7.228235 2.650353 13.492706 7.107765 18.853647 12.468706a35.659294 35.659294 0 0 1 11.685647 25.780706c0 11.565176-4.457412 27.587765-34.093176 68.487529h32.286118z m-532.540236 341.534118a46.622118 46.622118 0 0 1-30.539294-16.022588 57.825882 57.825882 0 0 1-16.143059-31.081412 169.381647 169.381647 0 0 1-3.614117-40.056471V388.76862733c0-15.119059 1.807059-27.587765 3.614117-37.345882 2.650353-12.468706 8.071529-22.287059 15.23953-30.298353 7.228235-8.854588 17.950118-14.215529 31.442823-15.962353 9.878588-0.903529 19.757176-1.807059 32.346353-1.807059h367.314824c30.539294 0 52.043294 8.011294 65.536 23.130353 11.685647 14.215529 17.950118 35.538824 17.950117 63.126588v46.260706c0 29.394824-6.264471 50.718118-20.660705 64.933647-13.432471 13.372235-34.093176 20.48-62.825412 20.48H326.415059c-12.589176 0-22.467765 0-31.442824-1.807059z m32.346353-129.867294h-0.903529v43.610353c0 5.360941 0.903529 7.107765 1.807059 8.011294h366.411294c-0.903529 0 0-2.650353 0-7.107765v-49.814588H327.318588v5.300706z m577.41553 527.480471c15.299765 11.565176 23.371294 24.877176 19.757176 39.152941 0 16.865882-9.878588 31.984941-26.925176 38.189176a36.743529 36.743529 0 0 1-17.046589 3.614118 64.451765 64.451765 0 0 1-31.442823-9.818353 2255.149176 2255.149176 0 0 0-139.14353-74.691765 2297.976471 2297.976471 0 0 0-155.407058-71.198117c-8.071529-4.397176-33.249882-15.058824-33.249883-39.152942 0-0.843294 0.903529-1.746824 0.90353-3.493647-5.421176 13.312-12.589176 26.684235-19.757177 39.152941-30.539294 53.308235-91.557647 93.364706-180.525176 119.145412-84.389647 24.937412-144.564706 37.345882-184.982588 37.345883-34.153412 0-45.778824-22.226824-45.778824-41.803295 0-8.854588 3.614118-36.442353 44.875294-44.453647 86.196706-11.565176 152.696471-26.684235 199.378824-43.610353 43.971765-16.865882 76.318118-39.152941 96.075294-66.68047 19.757176-27.587765 30.539294-71.137882 31.442823-129.867294 0-19.576471 9.035294-33.792 24.274824-39.996236H272.504471c-6.264471 0-8.975059 0-8.975059 14.21553v176.128c0 24.877176-17.046588 41.803294-43.068236 41.803294-25.178353 0-42.224941-16.022588-42.224941-41.803294v-184.139294c0-29.334588 8.071529-51.621647 23.311059-66.740706 15.299765-15.058824 37.767529-22.226824 68.306824-22.226824h489.411764c33.249882 0 55.717647 7.107765 70.053647 21.38353 13.492706 14.215529 20.660706 36.442353 20.660706 67.584v180.525176c0 24.937412-17.046588 41.803294-43.12847 41.803294-25.118118 0-42.164706-15.962353-42.164706-41.803294v-170.767059a31.503059 31.503059 0 0 0-1.807059-13.312c-1.807059-0.903529-3.614118-0.903529-7.228235-0.903529H524.890353c15.239529 6.204235 25.118118 20.48 25.118118 40.056471 0 37.345882-6.264471 72.884706-17.950118 107.580235 0.903529-0.843294 0.903529-1.807059 1.807059-2.650353 4.457412-8.914824 16.143059-15.119059 29.635764-15.119059 6.264471 0 15.239529 1.807059 54.814118 18.672941l98.785882 46.260706c20.600471 9.758118 40.357647 19.576471 60.114824 28.431059 20.660706 8.914824 40.417882 18.672941 59.271529 28.491294 19.757176 9.758118 35.056941 17.769412 45.778824 23.130353 9.938824 5.300706 16.263529 8.914824 18.913882 9.758118l3.614118 1.807059z"></path></symbol></svg><div id="__next"><header style="width:100%"><div class="_1CSgtu"><div class="_2oDcyf _1soATd"><a class="_1AawTM _1OhGeD" href="https://www.jianshu.com/" aria-label="简书" target="_blank" rel="noopener noreferrer"><svg class="wCYvWN" style="width:60px;height:30px" width="60" height="30" focusable="false" aria-hidden="true" viewBox="0 0 106 50" version="1.1"><g><path d="M79.6542664,49.2735656 L75.6602511,49.6932377 L75.6602511,27.3313525 L59.1137321,27.3313525 C58.6314725,27.3313525 57.9655336,26.8821721 57.8498237,26.1776639 L57.5346557,23.1870902 L75.6602511,23.1887295 L75.6602511,12.1260246 L62.1759992,12.1260246 C61.6180832,12.0858607 61.0229458,11.7788934 60.8894344,10.9870902 L60.5819534,7.93790984 L75.6602511,7.93790984 L75.6602511,0.409631148 L81.2074496,0.409631148 L81.2074496,7.93790984 L97.4727855,7.93790984 L97.4727855,23.1887295 L103.836831,23.1887295 L103.836831,38.1235656 C103.836831,42.2026639 100.70174,44.4715164 97.7187702,44.4715164 L92.357274,44.4715164 C91.6217473,44.4715164 91.0290374,43.9440574 90.9659229,43.3719262 L90.6681519,40.5223361 L92.1274725,40.5223361 L95.7933733,40.5223361 C97.0864115,40.5223361 98.3321137,39.6739754 98.3321137,38.1235656 L98.3321137,27.3313525 L81.2074496,27.3313525 L81.2074496,47.4452869 C81.2074496,48.5985656 80.4148771,49.1264344 79.6542664,49.2735656 L79.6542664,49.2735656 Z M81.260045,22.917418 L91.9745412,22.917418 L91.9745412,12.0514344 L81.260045,12.0514344 L81.260045,22.917418 Z M104.57519,13.9920082 L100.167289,13.9920082 C99.5871214,9.9170082 97.5274038,5.26987705 95.0355947,1.96209016 L100.167289,1.96209016 C102.583037,4.95553279 104.693327,8.85922131 105.720556,12.5608607 C105.867015,13.1711066 105.472144,13.9920082 104.57519,13.9920082 L104.57519,13.9920082 Z"></path><path d="M4.98236412,12.0515574 L9.99834885,12.0515574 C11.3953641,13.8056557 12.3169977,15.077377 13.7310053,18.5515574 C13.8337687,18.8339344 13.9130664,20.2007377 12.5900893,20.2007377 L8.57624962,20.2007377 C7.43047863,15.8630328 6.43521145,14.337623 4.97831832,12.0540164 C3.51980687,13.0105738 1.86507405,13.8138525 -4.04580153e-05,14.3802459 L-4.04580153e-05,10.3880328 C2.35987557,9.24172131 4.08662366,7.6892623 5.34608168,5.85278689 C6.43399771,4.2654918 7.18206641,2.47901639 7.58300534,0.409754098 L11.8043947,0.409754098 C12.772555,0.409754098 13.2313489,1.06877049 13.0962191,1.56139344 C12.9129443,2.1392623 12.5342573,2.99377049 12.1640664,3.78270492 L25.2676084,3.78270492 L25.0038221,6.30278689 C24.9370664,6.85483607 24.5227763,7.57532787 23.6181351,7.57532787 L17.5377,7.57532787 C18.2930511,9.24336066 18.7571046,10.7601639 18.9112496,11.3568852 C19.0508298,11.9036066 18.7004634,12.7810656 17.765074,12.7810656 L13.9850817,12.7810656 C13.7127992,10.9581148 13.4073412,9.70811475 12.633784,7.57532787 L9.82963893,7.57532787 C8.54266947,9.20852459 6.93891374,10.7679508 4.98236412,12.0515574 L4.98236412,12.0515574 Z M14.1651198,43.4847541 L14.1651198,22.1413115 L34.8367382,22.1413115 L34.8367382,36.8896721 C34.9253412,41.1093443 31.729158,43.4847541 28.4929214,43.4847541 L14.1651198,43.4847541 Z M35.3776618,49.3056557 C34.6793565,49.3056557 34.1008069,48.7921311 34.0028985,48.0851639 L33.669929,45.2757377 L38.4682496,45.2372131 C39.5310817,45.2372131 40.5696389,44.5277869 40.5696389,42.9769672 L40.5696389,18.4761475 L16.1390664,18.4761475 C15.6288908,18.4761475 15.0078603,18.2769672 14.819326,17.2298361 L14.5478527,14.3802459 L45.940845,14.3802459 L45.940845,43.4048361 C45.940845,45.4257377 44.1275168,49.2339344 39.6552878,49.3056557 L35.3776618,49.3056557 Z M6.84505115,49.2904918 L3.0626313,49.6933607 L3.0626313,20.2007377 L8.42250916,20.2007377 L8.42250916,47.3646721 C8.42250916,48.0146721 8.09399008,49.0794262 6.84505115,49.2904918 L6.84505115,49.2904918 Z M41.1040893,12.617541 L37.1335397,12.617541 C36.8025931,10.8986885 36.5436618,9.44581967 35.7462344,7.47942623 L32.2174863,7.47942623 C31.3132496,8.52245902 30.2645779,9.69581967 28.8404557,10.8204098 C27.3799214,11.9736885 25.5018603,13.1154918 22.9704023,13.9917213 L22.9704023,9.96672131 C27.0331962,7.6904918 29.0237305,4.6007377 29.9906771,0.409754098 L34.2080206,0.409754098 C35.3258756,0.409754098 35.6547992,1.21385246 35.5848069,1.4892623 C35.3121198,2.35811475 34.9075397,2.9892623 34.6032954,3.70360656 L48.620784,3.70360656 L48.3602344,6.23434426 C48.2724405,6.99745902 47.669616,7.47942623 47.0243107,7.47942623 L40.7173107,7.47942623 C41.4892496,9.14459016 41.945616,10.3318852 42.1398145,11.2503279 C42.223158,11.6478689 41.9775779,12.5761475 41.1040893,12.617541 L41.1040893,12.617541 Z M19.1422649,39.6040164 L27.579784,39.6040164 C29.230471,39.6040164 29.861616,38.5290164 29.861616,37.3347541 L29.861616,34.5634426 L19.1693718,34.5589344 L19.1422649,39.6040164 Z M19.1422649,30.6786066 L29.8620206,30.6786066 L29.8620206,26.0220492 L19.1422649,26.0220492 L19.1422649,30.6786066 Z"></path></g></svg></a><div class="_7hb9O4"><i aria-label="ic-nav-mode" tabindex="-1" class="anticon _1nZg8v"><svg width="1em" height="1em" fill="currentColor" aria-hidden="true" focusable="false" class=""><use xlink:href="#ic-nav-mode"></use></svg></i><span class="_1jKNin" aria-label="简书钻"><svg class="wCYvWN" style="width:54px;height:24px" width="54" height="24" focusable="false" aria-hidden="true" viewBox="0 0 50 22" version="1.1"><g transform="translate(1.000000, 4.000000)" fill="#EA6F5A" stroke="#EA6F5A" stroke-width="0.5"><path d="M6.97355121,0.977899795 L5.71487604,5.02704222 L14.0382941,5.02704222 L12.7812515,0.977899795 L6.97355121,0.977899795 Z M5.94914309,0.977899795 L5.39898286,0.977899795 C5.34645865,0.977985274 5.29616908,0.99894266 5.25940216,1.03606786 L1.33563333,5.02704222 L4.69046792,5.02704222 L5.94914309,0.977899795 Z M8.80687445,13.8613144 L4.56068234,5.99650966 L1.40664806,5.99650966 L8.80687445,13.8613144 Z M5.67079793,5.99650966 L9.99290234,14.0010793 L14.0962487,5.99650966 L5.67079793,5.99650966 Z M6.61929374,0.00843234872 L14.581108,0.00843234872 C14.8986337,0.00843234872 15.2014667,0.135271015 15.4234898,0.359864308 L19.6476429,4.6562209 C20.0841892,5.10085541 20.0917287,5.80620568 19.6647844,6.25988166 L10.8491606,15.6281688 C10.4068293,16.0970986 9.66444122,16.1231211 9.18970108,15.6863369 C9.1594994,15.6580607 9.1594994,15.6580607 9.13093026,15.6281688 L0.315306487,6.25988166 C-0.111412478,5.80599166 -0.10351395,5.10063881 0.333264249,4.6562209 L4.55741731,0.359864308 C4.7786002,0.135221626 5.08206407,0.00849721138 5.39898286,0.00843234872 L6.62011001,0.00843234872 L6.61929374,0.00843234872 Z M13.8056596,0.977899178 L15.0643348,5.02704222 L18.6452738,5.02704222 L14.721505,1.03606786 C14.6845399,0.998742398 14.6339153,0.977768057 14.581108,0.977899795 L13.8056596,0.977899178 Z M11.1487286,13.8879747 L18.5742591,5.99650966 L15.1949366,5.99650966 L11.1487286,13.8879747 Z"></path></g><g transform="translate(19.000000, 5.000000)"><path d="M5.16425826,0.266666667 C3.98605079,0.266666667 3.03092493,1.22179253 3.03092493,2.4 L3.03092493,8.73301908 L2.96783132,8.90526634 L1.31769477,10.8555055 C1.236217,10.9518012 1.19150756,11.0738592 1.19150756,11.2 C1.19150756,11.4945519 1.43028903,11.7333333 1.72484089,11.7333333 L26.5448138,11.7333333 C27.7230213,11.7333333 28.6781471,10.7782075 28.6781471,9.6 L28.6781471,2.4 C28.6781471,1.22179253 27.7230213,0.266666667 26.5448138,0.266666667 L5.16425826,0.266666667 Z" stroke="#EA6F5A" stroke-width="0.533333333" fill="#EA6F5A"></path><path d="M6.79203604,2 L7.57631592,2 L7.57631592,4.96927224 C7.96845586,4.26091644 8.52725527,3.9115903 9.25271416,3.9115903 C9.96836954,3.9115903 10.5369725,4.17358491 10.9487194,4.71698113 C11.3212523,5.20215633 11.5173223,5.80377358 11.5173223,6.54123989 C11.5173223,7.29811321 11.3212523,7.91913747 10.9487194,8.40431267 C10.527169,8.92830189 9.94876255,9.2 9.21350016,9.2 C8.42922028,9.2 7.87042087,8.87978437 7.52729842,8.2393531 L7.52729842,9.06415094 L6.79203604,9.06415094 L6.79203604,2 Z M9.08605468,4.55202156 C8.62529025,4.55202156 8.25275731,4.72668464 7.97825935,5.09541779 C7.6841544,5.45444744 7.54690542,5.92991914 7.54690542,6.51212938 L7.54690542,6.60916442 C7.54690542,7.17196765 7.6743509,7.62803235 7.92924186,7.97735849 C8.20373982,8.36549865 8.60568326,8.55956873 9.11546518,8.55956873 C9.66446109,8.55956873 10.076208,8.35579515 10.350706,7.96765499 C10.5859899,7.61832884 10.7134354,7.14285714 10.7134354,6.54123989 C10.7134354,5.93962264 10.5859899,5.47385445 10.331099,5.13423181 C10.0467975,4.74609164 9.6350506,4.55202156 9.08605468,4.55202156 Z M14.6250313,3.9115903 C15.4387217,3.9115903 16.0563421,4.18328841 16.468089,4.72668464 C16.840622,5.21185984 17.0366919,5.90080863 17.0562989,6.77412399 L13.0564716,6.77412399 C13.0956856,7.33692722 13.242738,7.77358491 13.517236,8.08409704 C13.7917339,8.39460916 14.1740704,8.54986523 14.6544418,8.54986523 C15.0661888,8.54986523 15.4093112,8.44312668 15.6642022,8.2393531 C15.8798791,8.06469003 16.0465386,7.80269542 16.1739841,7.45336927 L16.958264,7.45336927 C16.840622,7.93854447 16.6151415,8.32668464 16.2720191,8.63719677 C15.8504686,9.00592992 15.3112762,9.2 14.6544418,9.2 C13.9289829,9.2 13.340773,8.9574124 12.9094191,8.4916442 C12.4584582,8.006469 12.2427812,7.36603774 12.2427812,6.5509434 C12.2427812,5.81347709 12.4486547,5.19245283 12.8800086,4.69757412 C13.3113625,4.17358491 13.8897689,3.9115903 14.6250313,3.9115903 Z M14.6446383,4.56172507 C14.1936774,4.56172507 13.8309479,4.70727763 13.55645,4.99838275 C13.281952,5.28948787 13.1250961,5.67762803 13.0760786,6.17250674 L16.2426086,6.17250674 C16.1445736,5.09541779 15.6053812,4.56172507 14.6446383,4.56172507 Z M19.3307106,2.42695418 L19.3307106,4.04743935 L20.5855584,4.04743935 L20.5855584,4.69757412 L19.3307106,4.69757412 L19.3307106,7.89002695 C19.3307106,8.07439353 19.3601211,8.21024259 19.4385491,8.28787062 C19.5071736,8.36549865 19.634619,8.41401617 19.811082,8.41401617 L20.4581129,8.41401617 L20.4581129,9.06415094 L19.69344,9.06415094 C19.2816931,9.06415094 18.9777846,8.9574124 18.8013217,8.74393531 C18.6346622,8.54986523 18.5562342,8.26846361 18.5562342,7.89002695 L18.5562342,4.69757412 L17.5366704,4.69757412 L17.5366704,4.04743935 L18.5562342,4.04743935 L18.5562342,2.74716981 L19.3307106,2.42695418 Z M23.6638569,3.9115903 C24.3893158,3.9115903 24.9187047,4.09595687 25.2716307,4.47439353 C25.5657356,4.80431267 25.7225916,5.26037736 25.7225916,5.8425876 L25.7225916,9.06415094 L24.9873292,9.06415094 L24.9873292,8.21994609 C24.7912592,8.4916442 24.5265648,8.7245283 24.2030493,8.89919137 C23.8305164,9.09326146 23.408966,9.2 22.9482015,9.2 C22.4384196,9.2 22.0266727,9.06415094 21.7325677,8.81185984 C21.4188558,8.54986523 21.2619998,8.20053908 21.2619998,7.7541779 C21.2619998,7.11374663 21.5168907,6.64797844 22.0364762,6.35687332 C22.4482231,6.11428571 23.016826,5.98814016 23.7226779,5.98814016 L24.9383117,5.97843666 L24.9383117,5.81347709 C24.9383117,4.96927224 24.4971543,4.55202156 23.6148394,4.55202156 C23.212896,4.55202156 22.8893805,4.6296496 22.6540966,4.80431267 C22.3992056,4.97897574 22.2423496,5.23126685 22.1835286,5.58059299 L21.4090523,5.58059299 C21.4874803,5.00808625 21.7325677,4.58113208 22.1541181,4.29973046 C22.5266511,4.03773585 23.0266295,3.9115903 23.6638569,3.9115903 Z M24.9383117,6.58975741 L23.7716954,6.59946092 C22.6344896,6.59946092 22.0658867,6.98760108 22.0658867,7.74447439 C22.0658867,7.98706199 22.1541181,8.19083558 22.3403846,8.34609164 C22.5266511,8.4916442 22.7815421,8.56927224 23.114861,8.56927224 C23.6246429,8.56927224 24.0559969,8.41401617 24.4187263,8.10350404 C24.7618487,7.79299191 24.9383117,7.43396226 24.9383117,7.02641509 L24.9383117,6.58975741 Z" fill="#FFFFFF"></path></g></svg></span><a href="https://www.jianshu.com/sign_in" target="_blank" class="_2MpoKb _1OyPqC _1AT95S _2WY0RL" role="button" tabindex="-1"><span>登录</span></a><a href="https://www.jianshu.com/sign_up" target="_blank" class="_2MpoKb _1OyPqC _3Mi9q9 _2WY0RL" role="button" tabindex="-1"><span>注册</span></a><a href="https://www.jianshu.com/writer" target="_blank" class="_1OyPqC _3Mi9q9 _2WY0RL _1YbC5u" role="button" tabindex="-1"><i aria-label="ic-write" style="margin-right:2px" class="anticon"><svg width="1em" height="1em" fill="currentColor" aria-hidden="true" focusable="false" class=""><use xlink:href="#ic-write"></use></svg></i><span>写文章</span></a></div><div class="_1YyUun"><div class="_2RZATq"><nav class="_3JYrtj"><a class="hM7XFL _1OhGeD" href="https://www.jianshu.com/">首页</a><a class="hM7XFL _1OhGeD" href="https://www.jianshu.com/apps?utm_medium=desktop&amp;utm_source=navbar-apps">下载APP</a></nav><div class="MoRCpo"><div class="_31TNvD"><input type="search" class="_2q13cl G1b3UE" value="" placeholder="搜索" aria-label="搜索专题"><span class="x6-7Eb" role="button" tabindex="-1" aria-label="搜索"><i aria-label="icon: search" class="anticon anticon-search"><svg viewBox="64 64 896 896" focusable="false" class="" data-icon="search" width="1em" height="1em" fill="currentColor" aria-hidden="true"><path d="M909.6 854.5L649.9 594.8C690.2 542.7 712 479 712 412c0-80.2-31.3-155.4-87.9-212.1-56.6-56.7-132-87.9-212.1-87.9s-155.5 31.3-212.1 87.9C143.2 256.5 112 331.8 112 412c0 80.1 31.3 155.5 87.9 212.1C256.5 680.8 331.8 712 412 712c67 0 130.6-21.8 182.7-62l259.7 259.6a8.2 8.2 0 0 0 11.6 0l43.6-43.5a8.2 8.2 0 0 0 0-11.6zM570.4 570.4C528 612.7 471.8 636 412 636s-116-23.3-158.4-65.6C211.3 528 188 471.8 188 412s23.3-116.1 65.6-158.4C296 211.3 352.2 188 412 188s116.1 23.2 158.4 65.6S636 352.2 636 412s-23.3 116.1-65.6 158.4z"></path></svg></i></span></div></div></div></div></div><div class="_3t3lfz KEKfID"><div class="FTZkZo"><div class="_16zCst"><h1 class="_2zeTMs" title="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放">SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放</h1></div><div class="_26qd_C"><a class="qzhJKO" href="https://www.jianshu.com/u/1331c2256306"><img class="_2JlnTn" src="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/b7c8de10-60ca-437e-81da-5ab169cdbb45" alt=""><span class="_22gUMi">依然慢节奏</span></a><button data-locale="zh-CN" type="button" class="_1OyPqC _3Mi9q9"><span>关注</span></button><button type="button" class="_1OyPqC _3Mi9q9 _1YbC5u"><span>赞赏支持</span></button></div></div></div></div><div class="VYwngI"></div></header><div class="_21bLU4 _3kbg6I"><div class="_3VRLsv" role="main"><div class="_gp-ck"><section class="ouvJEz"><h1 class="_1RuRku">SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放</h1><div class="rEsl9f"><div class="_2mYfmT"><a class="_1OhGeD" href="https://www.jianshu.com/u/1331c2256306" target="_blank" rel="noopener noreferrer"><img class="_13D2Eh" src="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/b7c8de10-60ca-437e-81da-5ab169cdbb45(1)" alt=""></a><div style="margin-left: 8px;"><div class="_3U4Smb"><span class="FxYr8x"><a class="_1OhGeD" href="https://www.jianshu.com/u/1331c2256306" target="_blank" rel="noopener noreferrer">依然慢节奏</a></span><button data-locale="zh-CN" type="button" class="_3kba3h _1OyPqC _3Mi9q9 _34692-"><span>关注</span></button></div><div class="s-dsoj"><span class="_3tCVn5"><i aria-label="ic-diamond" class="anticon"><svg width="1em" height="1em" fill="currentColor" aria-hidden="true" focusable="false" class=""><use xlink:href="#ic-diamond"></use></svg></i><span>9</span></span><time datetime="2019-11-20T14:17:00.000Z">2019.11.20 22:17:00</time><span>字数 275</span><span>阅读 809</span></div></div></div></div><article class="_2rhmJa"><h4>一、功能目的</h4>
<p>SpringBoot 实现Http分片下载断点续传，从而实现H5页面的大视频播放问题，实现渐进式播放，每次只播放需要播放的内容就可以了，不需要加载整个文件到内存中；</p>
<h3>二、Http分片下载断点续传实现</h3>
<div class="_2Uzcx_"><button class="VJbwyy" type="button" aria-label="复制代码"><i aria-label="icon: copy" class="anticon anticon-copy"><svg viewBox="64 64 896 896" focusable="false" class="" data-icon="copy" width="1em" height="1em" fill="currentColor" aria-hidden="true"><path d="M832 64H296c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h496v688c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8V96c0-17.7-14.3-32-32-32zM704 192H192c-17.7 0-32 14.3-32 32v530.7c0 8.5 3.4 16.6 9.4 22.6l173.3 173.3c2.2 2.2 4.7 4 7.4 5.5v1.9h4.2c3.5 1.3 7.2 2 11 2H704c17.7 0 32-14.3 32-32V224c0-17.7-14.3-32-32-32zM350 856.2L263.9 770H350v86.2zM664 888H414V746c0-22.1-17.9-40-40-40H232V264h432v624z"></path></svg></i></button><pre class="line-numbers  language-kotlin"><code class="  language-kotlin"><span class="token keyword">package</span> com<span class="token punctuation">.</span>unnet<span class="token punctuation">.</span>yjs<span class="token punctuation">.</span>controller<span class="token punctuation">.</span>api<span class="token punctuation">.</span>v1<span class="token punctuation">;</span>

<span class="token keyword">import</span> com<span class="token punctuation">.</span>unnet<span class="token punctuation">.</span>yjs<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span>HttpMethod<span class="token punctuation">;</span>
<span class="token keyword">import</span> com<span class="token punctuation">.</span>unnet<span class="token punctuation">.</span>yjs<span class="token punctuation">.</span>base<span class="token punctuation">.</span>ContainerProperties<span class="token punctuation">;</span>
<span class="token keyword">import</span> com<span class="token punctuation">.</span>unnet<span class="token punctuation">.</span>yjs<span class="token punctuation">.</span>entity<span class="token punctuation">.</span>OssFileRecord<span class="token punctuation">;</span>
<span class="token keyword">import</span> com<span class="token punctuation">.</span>unnet<span class="token punctuation">.</span>yjs<span class="token punctuation">.</span>service<span class="token punctuation">.</span>OssFileRecordService<span class="token punctuation">;</span>
<span class="token keyword">import</span> com<span class="token punctuation">.</span>unnet<span class="token punctuation">.</span>yjs<span class="token punctuation">.</span>util<span class="token punctuation">.</span>IOssOperation<span class="token punctuation">;</span>
<span class="token keyword">import</span> com<span class="token punctuation">.</span>xiaoleilu<span class="token punctuation">.</span>hutool<span class="token punctuation">.</span>util<span class="token punctuation">.</span>StrUtil<span class="token punctuation">;</span>
<span class="token keyword">import</span> io<span class="token punctuation">.</span>swagger<span class="token punctuation">.</span>annotations<span class="token punctuation">.</span>Api<span class="token punctuation">;</span>
<span class="token keyword">import</span> io<span class="token punctuation">.</span>swagger<span class="token punctuation">.</span>annotations<span class="token punctuation">.</span>ApiImplicitParam<span class="token punctuation">;</span>
<span class="token keyword">import</span> io<span class="token punctuation">.</span>swagger<span class="token punctuation">.</span>annotations<span class="token punctuation">.</span>ApiImplicitParams<span class="token punctuation">;</span>
<span class="token keyword">import</span> io<span class="token punctuation">.</span>swagger<span class="token punctuation">.</span>annotations<span class="token punctuation">.</span>ApiOperation<span class="token punctuation">;</span>
<span class="token keyword">import</span> org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>catalina<span class="token punctuation">.</span>connector<span class="token punctuation">.</span>ClientAbortException<span class="token punctuation">;</span>
<span class="token keyword">import</span> org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>tomcat<span class="token punctuation">.</span>util<span class="token punctuation">.</span>http<span class="token punctuation">.</span>fileupload<span class="token punctuation">.</span>IOUtils<span class="token punctuation">;</span>
<span class="token keyword">import</span> org<span class="token punctuation">.</span>slf4j<span class="token punctuation">.</span>Logger<span class="token punctuation">;</span>
<span class="token keyword">import</span> org<span class="token punctuation">.</span>slf4j<span class="token punctuation">.</span>LoggerFactory<span class="token punctuation">;</span>
<span class="token keyword">import</span> org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>beans<span class="token punctuation">.</span>factory<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span>Autowired<span class="token punctuation">;</span>
<span class="token keyword">import</span> org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>beans<span class="token punctuation">.</span>factory<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span>Qualifier<span class="token punctuation">;</span>
<span class="token keyword">import</span> org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>core<span class="token punctuation">.</span>io<span class="token punctuation">.</span>InputStreamResource<span class="token punctuation">;</span>
<span class="token keyword">import</span> org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>http<span class="token punctuation">.</span>HttpHeaders<span class="token punctuation">;</span>
<span class="token keyword">import</span> org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>http<span class="token punctuation">.</span>HttpStatus<span class="token punctuation">;</span>
<span class="token keyword">import</span> org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>http<span class="token punctuation">.</span>MediaType<span class="token punctuation">;</span>
<span class="token keyword">import</span> org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>http<span class="token punctuation">.</span>ResponseEntity<span class="token punctuation">;</span>
<span class="token keyword">import</span> org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>web<span class="token punctuation">.</span>bind<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span><span class="token operator">*</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> javax<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span>Resource<span class="token punctuation">;</span>
<span class="token keyword">import</span> javax<span class="token punctuation">.</span>servlet<span class="token punctuation">.</span>http<span class="token punctuation">.</span>HttpServletRequest<span class="token punctuation">;</span>
<span class="token keyword">import</span> javax<span class="token punctuation">.</span>servlet<span class="token punctuation">.</span>http<span class="token punctuation">.</span>HttpServletResponse<span class="token punctuation">;</span>
<span class="token keyword">import</span> java<span class="token punctuation">.</span>io<span class="token punctuation">.</span><span class="token operator">*</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> java<span class="token punctuation">.</span>nio<span class="token punctuation">.</span>charset<span class="token punctuation">.</span>StandardCharsets<span class="token punctuation">;</span>
<span class="token keyword">import</span> java<span class="token punctuation">.</span>util<span class="token punctuation">.</span>Objects<span class="token punctuation">;</span>

<span class="token comment">/**
 * Email: love1208tt@foxmail.com
 * Copyright (c)  2019. missbe
 * @author lyg   19-7-29 下午9:21
 *
 *
 **/</span>
<span class="token annotation builtin">@RestController</span>
<span class="token annotation builtin">@Api</span><span class="token punctuation">(</span>tags <span class="token operator">=</span> <span class="token string">"OssStreamConvertController"</span><span class="token punctuation">,</span> description <span class="token operator">=</span> <span class="token string">"文件上传控制器"</span><span class="token punctuation">)</span>
<span class="token annotation builtin">@RequestMapping</span><span class="token punctuation">(</span><span class="token string">"/api/v1/resource/file/"</span><span class="token punctuation">)</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> OssStreamConvertController <span class="token punctuation">{</span>
    <span class="token keyword">private</span> static <span class="token keyword">final</span> Logger LOGGER <span class="token operator">=</span> LoggerFactory<span class="token punctuation">.</span><span class="token function">getLogger</span><span class="token punctuation">(</span>OssStreamConvertController<span class="token punctuation">.</span>class<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token annotation builtin">@Resource</span>
    <span class="token keyword">private</span> ContainerProperties containerProperties<span class="token punctuation">;</span>

    <span class="token annotation builtin">@Autowired</span>
    <span class="token annotation builtin">@Qualifier</span><span class="token punctuation">(</span><span class="token string">"paasOssTool"</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> IOssOperation paasOssTool<span class="token punctuation">;</span>
    <span class="token annotation builtin">@Autowired</span>
    <span class="token annotation builtin">@Qualifier</span><span class="token punctuation">(</span><span class="token string">"minIoOssTool"</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> IOssOperation minIoOssTool<span class="token punctuation">;</span>

    <span class="token annotation builtin">@Resource</span>
    <span class="token keyword">private</span> OssFileRecordService ossFileRecordService<span class="token punctuation">;</span>


    <span class="token comment">/**
     * 对象存储中转请求链接-根据文件名字请求对象存储的文件流
     *
     * @param fileName 文件名称
     */</span>
    <span class="token annotation builtin">@GetMapping</span><span class="token punctuation">(</span><span class="token string">"video/{fileName}"</span><span class="token punctuation">)</span>
    <span class="token annotation builtin">@ApiOperation</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">"对象存储文件流中转接口"</span><span class="token punctuation">,</span> httpMethod <span class="token operator">=</span> HttpMethod<span class="token punctuation">.</span>GET<span class="token punctuation">)</span>
    <span class="token annotation builtin">@ApiImplicitParams</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
            <span class="token annotation builtin">@ApiImplicitParam</span><span class="token punctuation">(</span>name <span class="token operator">=</span> <span class="token string">"fileName"</span><span class="token punctuation">,</span> value <span class="token operator">=</span> <span class="token string">"文件名称"</span><span class="token punctuation">,</span> paramType <span class="token operator">=</span> <span class="token string">"path"</span><span class="token punctuation">)</span>
    <span class="token punctuation">}</span><span class="token punctuation">)</span>
    <span class="token keyword">public</span> void <span class="token function">videoPlayer</span><span class="token punctuation">(</span><span class="token annotation builtin">@PathVariable</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">"fileName"</span><span class="token punctuation">)</span> String fileName<span class="token punctuation">,</span> HttpServletRequest request<span class="token punctuation">,</span>HttpServletResponse response<span class="token punctuation">)</span> throws IOException <span class="token punctuation">{</span>
        <span class="token keyword">if</span><span class="token punctuation">(</span>paasOssTool <span class="token operator">==</span> <span class="token keyword">null</span> <span class="token operator">||</span> minIoOssTool <span class="token operator">==</span> <span class="token keyword">null</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
            OutputStream <span class="token keyword">out</span> <span class="token operator">=</span> response<span class="token punctuation">.</span><span class="token function">getOutputStream</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">out</span><span class="token punctuation">.</span><span class="token function">write</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token string">"OSS文件服务器配置出现问题,请修复后重试."</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">getBytes</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">out</span><span class="token punctuation">.</span><span class="token function">flush</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">out</span><span class="token punctuation">.</span><span class="token function">close</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">return</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>

        <span class="token comment">///是否开启本地缓存视频mp4文件</span>
        String filePath <span class="token operator">=</span> containerProperties<span class="token punctuation">.</span><span class="token function">getFileCacheLocation</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">+</span> fileName<span class="token punctuation">;</span>
        File file <span class="token operator">=</span> new <span class="token function">File</span><span class="token punctuation">(</span>filePath<span class="token punctuation">)</span><span class="token punctuation">;</span>
        File parentDir <span class="token operator">=</span> file<span class="token punctuation">.</span><span class="token function">getParentFile</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">!</span>parentDir<span class="token punctuation">.</span><span class="token function">exists</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
           boolean isMakeParentDir <span class="token operator">=</span> parentDir<span class="token punctuation">.</span><span class="token function">mkdirs</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
           <span class="token keyword">if</span><span class="token punctuation">(</span>isMakeParentDir<span class="token punctuation">)</span><span class="token punctuation">{</span>
               LOGGER<span class="token punctuation">.</span><span class="token function">info</span><span class="token punctuation">(</span><span class="token string">"创建文件夹{}成功."</span><span class="token punctuation">,</span>parentDir<span class="token punctuation">.</span><span class="token function">getAbsolutePath</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
           <span class="token punctuation">}</span><span class="token keyword">else</span> <span class="token punctuation">{</span>
               LOGGER<span class="token punctuation">.</span><span class="token function">error</span><span class="token punctuation">(</span><span class="token string">"创建文件夹{}失败."</span><span class="token punctuation">,</span>parentDir<span class="token punctuation">.</span><span class="token function">getAbsolutePath</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
           <span class="token punctuation">}</span>
        <span class="token punctuation">}</span><span class="token comment">//end if</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">!</span>file<span class="token punctuation">.</span><span class="token function">exists</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token comment">///本地文件不存在,从OSS下载到本地</span>
            boolean isMakeNewFile <span class="token operator">=</span> file<span class="token punctuation">.</span><span class="token function">createNewFile</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">if</span><span class="token punctuation">(</span>isMakeNewFile<span class="token punctuation">)</span><span class="token punctuation">{</span>
                LOGGER<span class="token punctuation">.</span><span class="token function">info</span><span class="token punctuation">(</span><span class="token string">"创建文件{}成功."</span><span class="token punctuation">,</span>file<span class="token punctuation">.</span><span class="token function">getAbsolutePath</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span><span class="token keyword">else</span> <span class="token punctuation">{</span>
                LOGGER<span class="token punctuation">.</span><span class="token function">error</span><span class="token punctuation">(</span><span class="token string">"创建文件{}失败."</span><span class="token punctuation">,</span>file<span class="token punctuation">.</span><span class="token function">getAbsolutePath</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
            ByteArrayOutputStream baos <span class="token operator">=</span> new <span class="token function">ByteArrayOutputStream</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            InputStream <span class="token keyword">is</span> <span class="token operator">=</span> <span class="token keyword">null</span><span class="token punctuation">;</span>
            <span class="token keyword">try</span> <span class="token punctuation">{</span>
                <span class="token keyword">if</span> <span class="token punctuation">(</span>StrUtil<span class="token punctuation">.</span><span class="token function">equalsIgnoreCase</span><span class="token punctuation">(</span>containerProperties<span class="token punctuation">.</span><span class="token function">getFileUploadType</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token string">"myOss"</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
                    <span class="token keyword">is</span> <span class="token operator">=</span> minIoOssTool<span class="token punctuation">.</span><span class="token function">load</span><span class="token punctuation">(</span>fileName<span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token punctuation">}</span>
                <span class="token keyword">if</span> <span class="token punctuation">(</span>StrUtil<span class="token punctuation">.</span><span class="token function">equalsIgnoreCase</span><span class="token punctuation">(</span>containerProperties<span class="token punctuation">.</span><span class="token function">getFileUploadType</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token string">"paas"</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
                    <span class="token keyword">is</span> <span class="token operator">=</span> paasOssTool<span class="token punctuation">.</span><span class="token function">load</span><span class="token punctuation">(</span>fileName<span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token punctuation">}</span>
            <span class="token punctuation">}</span> <span class="token keyword">catch</span> <span class="token punctuation">(</span>Exception e<span class="token punctuation">)</span> <span class="token punctuation">{</span>
                e<span class="token punctuation">.</span><span class="token function">printStackTrace</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                e<span class="token punctuation">.</span><span class="token function">printStackTrace</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                LOGGER<span class="token punctuation">.</span><span class="token function">error</span><span class="token punctuation">(</span><span class="token string">"对象存储加载文件失败,msg:"</span><span class="token operator">+</span>e<span class="token punctuation">.</span><span class="token function">getLocalizedMessage</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                OutputStream <span class="token keyword">out</span> <span class="token operator">=</span> response<span class="token punctuation">.</span><span class="token function">getOutputStream</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token keyword">out</span><span class="token punctuation">.</span><span class="token function">write</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token string">"对象存储加载文件失败,msg:"</span><span class="token operator">+</span>e<span class="token punctuation">.</span><span class="token function">getLocalizedMessage</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">getBytes</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token keyword">out</span><span class="token punctuation">.</span><span class="token function">flush</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token keyword">out</span><span class="token punctuation">.</span><span class="token function">close</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token keyword">return</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
            <span class="token comment">////判断流不为空</span>
            Objects<span class="token punctuation">.</span><span class="token function">requireNonNull</span><span class="token punctuation">(</span><span class="token keyword">is</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

            BufferedOutputStream bos <span class="token operator">=</span> new <span class="token function">BufferedOutputStream</span><span class="token punctuation">(</span>new <span class="token function">FileOutputStream</span><span class="token punctuation">(</span>file<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            byte<span class="token punctuation">[</span><span class="token punctuation">]</span> buffer <span class="token operator">=</span> new byte<span class="token punctuation">[</span><span class="token number">4096</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
            int length<span class="token punctuation">;</span>
            <span class="token keyword">while</span> <span class="token punctuation">(</span><span class="token punctuation">(</span>length <span class="token operator">=</span> <span class="token keyword">is</span><span class="token punctuation">.</span><span class="token function">read</span><span class="token punctuation">(</span>buffer<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token operator">!=</span> <span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
                bos<span class="token punctuation">.</span><span class="token function">write</span><span class="token punctuation">(</span>buffer<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> length<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
            bos<span class="token punctuation">.</span><span class="token function">flush</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            bos<span class="token punctuation">.</span><span class="token function">close</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span><span class="token comment">///end if</span>
        LOGGER<span class="token punctuation">.</span><span class="token function">info</span><span class="token punctuation">(</span><span class="token string">"文件：{}，总长度：{}"</span><span class="token punctuation">,</span>file<span class="token punctuation">.</span><span class="token function">getName</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span>file<span class="token punctuation">.</span><span class="token function">length</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">///对文件执行分块</span>
        <span class="token function">fileChunkDownload</span><span class="token punctuation">(</span>filePath<span class="token punctuation">,</span>request<span class="token punctuation">,</span>response<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">/////添加文件访问记录</span>
        OssFileRecord ossFileRecord <span class="token operator">=</span> ossFileRecordService<span class="token punctuation">.</span><span class="token function">findByFileName</span><span class="token punctuation">(</span>fileName<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span>Objects<span class="token punctuation">.</span><span class="token function">nonNull</span><span class="token punctuation">(</span>ossFileRecord<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            ossFileRecord<span class="token punctuation">.</span><span class="token function">setFileLength</span><span class="token punctuation">(</span>String<span class="token punctuation">.</span><span class="token function">valueOf</span><span class="token punctuation">(</span>file<span class="token punctuation">.</span><span class="token function">length</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            ossFileRecord<span class="token punctuation">.</span><span class="token function">setVisitCount</span><span class="token punctuation">(</span>ossFileRecord<span class="token punctuation">.</span><span class="token function">getVisitCount</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span><span class="token keyword">else</span><span class="token punctuation">{</span>
            ossFileRecord <span class="token operator">=</span> new <span class="token function">OssFileRecord</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            ossFileRecord<span class="token punctuation">.</span><span class="token function">setFileName</span><span class="token punctuation">(</span>fileName<span class="token punctuation">)</span><span class="token punctuation">;</span>
            ossFileRecord<span class="token punctuation">.</span><span class="token function">setFileLength</span><span class="token punctuation">(</span>String<span class="token punctuation">.</span><span class="token function">valueOf</span><span class="token punctuation">(</span>file<span class="token punctuation">.</span><span class="token function">length</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            ossFileRecord<span class="token punctuation">.</span><span class="token function">setVisitCount</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            ossFileRecord<span class="token punctuation">.</span><span class="token function">setRemarks</span><span class="token punctuation">(</span><span class="token string">"OssFileRecord"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        ossFileRecordService<span class="token punctuation">.</span><span class="token function">insertOrUpdate</span><span class="token punctuation">(</span>ossFileRecord<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token comment">/**
     * 文件支持分块下载和断点续传
     * @param filePath 文件完整路径
     * @param request 请求
     * @param response 响应
     */</span>
    <span class="token keyword">private</span> void <span class="token function">fileChunkDownload</span><span class="token punctuation">(</span>String filePath<span class="token punctuation">,</span> HttpServletRequest request<span class="token punctuation">,</span> HttpServletResponse response<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        String range <span class="token operator">=</span> request<span class="token punctuation">.</span><span class="token function">getHeader</span><span class="token punctuation">(</span><span class="token string">"Range"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        LOGGER<span class="token punctuation">.</span><span class="token function">info</span><span class="token punctuation">(</span><span class="token string">"current request rang:"</span> <span class="token operator">+</span> range<span class="token punctuation">)</span><span class="token punctuation">;</span>
        File file <span class="token operator">=</span> new <span class="token function">File</span><span class="token punctuation">(</span>filePath<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//开始下载位置</span>
        long startByte <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
        <span class="token comment">//结束下载位置</span>
        long endByte <span class="token operator">=</span> file<span class="token punctuation">.</span><span class="token function">length</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">-</span> <span class="token number">1</span><span class="token punctuation">;</span>
        LOGGER<span class="token punctuation">.</span><span class="token function">info</span><span class="token punctuation">(</span><span class="token string">"文件开始位置：{}，文件结束位置：{}，文件总长度：{}"</span><span class="token punctuation">,</span> startByte<span class="token punctuation">,</span> endByte<span class="token punctuation">,</span> file<span class="token punctuation">.</span><span class="token function">length</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

        <span class="token comment">//有range的话</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span>range <span class="token operator">!=</span> <span class="token keyword">null</span> <span class="token operator">&amp;&amp;</span> range<span class="token punctuation">.</span><span class="token function">contains</span><span class="token punctuation">(</span><span class="token string">"bytes="</span><span class="token punctuation">)</span> <span class="token operator">&amp;&amp;</span> range<span class="token punctuation">.</span><span class="token function">contains</span><span class="token punctuation">(</span><span class="token string">"-"</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            range <span class="token operator">=</span> range<span class="token punctuation">.</span><span class="token function">substring</span><span class="token punctuation">(</span>range<span class="token punctuation">.</span><span class="token function">lastIndexOf</span><span class="token punctuation">(</span><span class="token string">"="</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">trim</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            String<span class="token punctuation">[</span><span class="token punctuation">]</span> ranges <span class="token operator">=</span> range<span class="token punctuation">.</span><span class="token function">split</span><span class="token punctuation">(</span><span class="token string">"-"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">try</span> <span class="token punctuation">{</span>
                <span class="token comment">//判断range的类型</span>
                <span class="token keyword">if</span> <span class="token punctuation">(</span>ranges<span class="token punctuation">.</span>length <span class="token operator">==</span> <span class="token number">1</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
                    <span class="token comment">//类型一：bytes=-2343</span>
                    <span class="token keyword">if</span> <span class="token punctuation">(</span>range<span class="token punctuation">.</span><span class="token function">startsWith</span><span class="token punctuation">(</span><span class="token string">"-"</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
                        endByte <span class="token operator">=</span> Long<span class="token punctuation">.</span><span class="token function">parseLong</span><span class="token punctuation">(</span>ranges<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                    <span class="token punctuation">}</span>
                    <span class="token comment">//类型二：bytes=2343-</span>
                    <span class="token keyword">else</span> <span class="token keyword">if</span> <span class="token punctuation">(</span>range<span class="token punctuation">.</span><span class="token function">endsWith</span><span class="token punctuation">(</span><span class="token string">"-"</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
                        startByte <span class="token operator">=</span> Long<span class="token punctuation">.</span><span class="token function">parseLong</span><span class="token punctuation">(</span>ranges<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                    <span class="token punctuation">}</span>
                <span class="token punctuation">}</span>
                <span class="token comment">//类型三：bytes=22-2343</span>
                <span class="token keyword">else</span> <span class="token keyword">if</span> <span class="token punctuation">(</span>ranges<span class="token punctuation">.</span>length <span class="token operator">==</span> <span class="token number">2</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
                    startByte <span class="token operator">=</span> Long<span class="token punctuation">.</span><span class="token function">parseLong</span><span class="token punctuation">(</span>ranges<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                    endByte <span class="token operator">=</span> Long<span class="token punctuation">.</span><span class="token function">parseLong</span><span class="token punctuation">(</span>ranges<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token punctuation">}</span>

            <span class="token punctuation">}</span> <span class="token keyword">catch</span> <span class="token punctuation">(</span>NumberFormatException e<span class="token punctuation">)</span> <span class="token punctuation">{</span>
                startByte <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
                endByte <span class="token operator">=</span> file<span class="token punctuation">.</span><span class="token function">length</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">-</span> <span class="token number">1</span><span class="token punctuation">;</span>
                LOGGER<span class="token punctuation">.</span><span class="token function">error</span><span class="token punctuation">(</span><span class="token string">"Range Occur Error,Message:{}"</span><span class="token punctuation">,</span>e<span class="token punctuation">.</span><span class="token function">getLocalizedMessage</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
        <span class="token punctuation">}</span>

        <span class="token comment">//要下载的长度</span>
        long contentLength <span class="token operator">=</span> endByte <span class="token operator">-</span> startByte <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">;</span>
        <span class="token comment">//文件名</span>
        String fileName <span class="token operator">=</span> file<span class="token punctuation">.</span><span class="token function">getName</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//文件类型</span>
        String contentType <span class="token operator">=</span> request<span class="token punctuation">.</span><span class="token function">getServletContext</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">getMimeType</span><span class="token punctuation">(</span>fileName<span class="token punctuation">)</span><span class="token punctuation">;</span>

        <span class="token comment">////解决下载文件时文件名乱码问题</span>
        byte<span class="token punctuation">[</span><span class="token punctuation">]</span> fileNameBytes <span class="token operator">=</span> fileName<span class="token punctuation">.</span><span class="token function">getBytes</span><span class="token punctuation">(</span>StandardCharsets<span class="token punctuation">.</span>UTF_8<span class="token punctuation">)</span><span class="token punctuation">;</span>
        fileName <span class="token operator">=</span> new <span class="token function">String</span><span class="token punctuation">(</span>fileNameBytes<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> fileNameBytes<span class="token punctuation">.</span>length<span class="token punctuation">,</span> StandardCharsets<span class="token punctuation">.</span>ISO_8859_1<span class="token punctuation">)</span><span class="token punctuation">;</span>

        <span class="token comment">//各种响应头设置     </span>
        <span class="token comment">//支持断点续传，获取部分字节内容：</span>
        response<span class="token punctuation">.</span><span class="token function">setHeader</span><span class="token punctuation">(</span><span class="token string">"Accept-Ranges"</span><span class="token punctuation">,</span> <span class="token string">"bytes"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//http状态码要为206：表示获取部分内容</span>
        response<span class="token punctuation">.</span><span class="token function">setStatus</span><span class="token punctuation">(</span>HttpServletResponse<span class="token punctuation">.</span>SC_PARTIAL_CONTENT<span class="token punctuation">)</span><span class="token punctuation">;</span>
        response<span class="token punctuation">.</span><span class="token function">setContentType</span><span class="token punctuation">(</span>contentType<span class="token punctuation">)</span><span class="token punctuation">;</span>
        response<span class="token punctuation">.</span><span class="token function">setHeader</span><span class="token punctuation">(</span><span class="token string">"Content-Type"</span><span class="token punctuation">,</span> contentType<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//inline表示浏览器直接使用，attachment表示下载，fileName表示下载的文件名</span>
        response<span class="token punctuation">.</span><span class="token function">setHeader</span><span class="token punctuation">(</span><span class="token string">"Content-Disposition"</span><span class="token punctuation">,</span> <span class="token string">"inline;filename="</span> <span class="token operator">+</span> fileName<span class="token punctuation">)</span><span class="token punctuation">;</span>
        response<span class="token punctuation">.</span><span class="token function">setHeader</span><span class="token punctuation">(</span><span class="token string">"Content-Length"</span><span class="token punctuation">,</span> String<span class="token punctuation">.</span><span class="token function">valueOf</span><span class="token punctuation">(</span>contentLength<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>       
        <span class="token comment">// Content-Range，格式为：[要下载的开始位置]-[结束位置]/[文件总大小]</span>
        response<span class="token punctuation">.</span><span class="token function">setHeader</span><span class="token punctuation">(</span><span class="token string">"Content-Range"</span><span class="token punctuation">,</span> <span class="token string">"bytes "</span> <span class="token operator">+</span> startByte <span class="token operator">+</span> <span class="token string">"-"</span> <span class="token operator">+</span> endByte <span class="token operator">+</span> <span class="token string">"/"</span> <span class="token operator">+</span> file<span class="token punctuation">.</span><span class="token function">length</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

        BufferedOutputStream outputStream <span class="token operator">=</span> <span class="token keyword">null</span><span class="token punctuation">;</span>
        RandomAccessFile randomAccessFile <span class="token operator">=</span> <span class="token keyword">null</span><span class="token punctuation">;</span>
        <span class="token comment">//已传送数据大小</span>
        long transmitted <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
        <span class="token keyword">try</span> <span class="token punctuation">{</span>
            randomAccessFile <span class="token operator">=</span> new <span class="token function">RandomAccessFile</span><span class="token punctuation">(</span>file<span class="token punctuation">,</span> <span class="token string">"r"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            outputStream <span class="token operator">=</span> new <span class="token function">BufferedOutputStream</span><span class="token punctuation">(</span>response<span class="token punctuation">.</span><span class="token function">getOutputStream</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            byte<span class="token punctuation">[</span><span class="token punctuation">]</span> buff <span class="token operator">=</span> new byte<span class="token punctuation">[</span><span class="token number">4096</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
            int len <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
            randomAccessFile<span class="token punctuation">.</span><span class="token function">seek</span><span class="token punctuation">(</span>startByte<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token comment">//坑爹地方四：判断是否到了最后不足4096（buff的length）个byte这个逻辑（(transmitted + len) &lt;= contentLength）要放前面！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！</span>
            <span class="token comment">//不然会会先读取randomAccessFile，造成后面读取位置出错，找了一天才发现问题所在</span>
            <span class="token keyword">while</span> <span class="token punctuation">(</span><span class="token punctuation">(</span>transmitted <span class="token operator">+</span> len<span class="token punctuation">)</span> <span class="token operator">&lt;=</span> contentLength <span class="token operator">&amp;&amp;</span> <span class="token punctuation">(</span>len <span class="token operator">=</span> randomAccessFile<span class="token punctuation">.</span><span class="token function">read</span><span class="token punctuation">(</span>buff<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token operator">!=</span> <span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
                outputStream<span class="token punctuation">.</span><span class="token function">write</span><span class="token punctuation">(</span>buff<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> len<span class="token punctuation">)</span><span class="token punctuation">;</span>
                transmitted <span class="token operator">+=</span> len<span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
            <span class="token comment">//处理不足buff.length部分</span>
            <span class="token keyword">if</span> <span class="token punctuation">(</span>transmitted <span class="token operator">&lt;</span> contentLength<span class="token punctuation">)</span> <span class="token punctuation">{</span>
                len <span class="token operator">=</span> randomAccessFile<span class="token punctuation">.</span><span class="token function">read</span><span class="token punctuation">(</span>buff<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token punctuation">(</span>int<span class="token punctuation">)</span> <span class="token punctuation">(</span>contentLength <span class="token operator">-</span> transmitted<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                outputStream<span class="token punctuation">.</span><span class="token function">write</span><span class="token punctuation">(</span>buff<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> len<span class="token punctuation">)</span><span class="token punctuation">;</span>
                transmitted <span class="token operator">+=</span> len<span class="token punctuation">;</span>
            <span class="token punctuation">}</span>

            outputStream<span class="token punctuation">.</span><span class="token function">flush</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            response<span class="token punctuation">.</span><span class="token function">flushBuffer</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            randomAccessFile<span class="token punctuation">.</span><span class="token function">close</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
           LOGGER<span class="token punctuation">.</span><span class="token function">info</span><span class="token punctuation">(</span><span class="token string">"下载完毕："</span> <span class="token operator">+</span> startByte <span class="token operator">+</span> <span class="token string">"-"</span> <span class="token operator">+</span> endByte <span class="token operator">+</span> <span class="token string">"："</span> <span class="token operator">+</span> transmitted<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span> <span class="token keyword">catch</span> <span class="token punctuation">(</span>ClientAbortException e<span class="token punctuation">)</span> <span class="token punctuation">{</span>
            LOGGER<span class="token punctuation">.</span><span class="token function">warn</span><span class="token punctuation">(</span><span class="token string">"用户停止下载："</span> <span class="token operator">+</span> startByte <span class="token operator">+</span> <span class="token string">"-"</span> <span class="token operator">+</span> endByte <span class="token operator">+</span> <span class="token string">"："</span> <span class="token operator">+</span> transmitted<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token comment">//捕获此异常表示拥护停止下载</span>
        <span class="token punctuation">}</span> <span class="token keyword">catch</span> <span class="token punctuation">(</span>IOException e<span class="token punctuation">)</span> <span class="token punctuation">{</span>
            e<span class="token punctuation">.</span><span class="token function">printStackTrace</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            LOGGER<span class="token punctuation">.</span><span class="token function">error</span><span class="token punctuation">(</span><span class="token string">"用户下载IO异常，Message：{}"</span><span class="token punctuation">,</span> e<span class="token punctuation">.</span><span class="token function">getLocalizedMessage</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span> <span class="token keyword">finally</span> <span class="token punctuation">{</span>
            <span class="token keyword">try</span> <span class="token punctuation">{</span>
                <span class="token keyword">if</span> <span class="token punctuation">(</span>randomAccessFile <span class="token operator">!=</span> <span class="token keyword">null</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
                    randomAccessFile<span class="token punctuation">.</span><span class="token function">close</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token punctuation">}</span>
            <span class="token punctuation">}</span> <span class="token keyword">catch</span> <span class="token punctuation">(</span>IOException e<span class="token punctuation">)</span> <span class="token punctuation">{</span>
                e<span class="token punctuation">.</span><span class="token function">printStackTrace</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
        <span class="token punctuation">}</span><span class="token comment">///end try</span>
    <span class="token punctuation">}</span>

 <span class="token punctuation">}</span>
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre></div>
<blockquote>
<p>ps：需要注意的几个方面:</p>
<ul>
<li>Http状态码为206，表示获取部分内容；</li>
<li>Content-Range，格式为[要下载的开始位置]-[结束位置]/[文件总大小]；</li>
<li>Accept-Ranges 设置为bytes；<br>
可以参考：</li>
<li><a href="https://links.jianshu.com/go?to=https%3A%2F%2Fwww.ibm.com%2Fdeveloperworks%2Fcn%2Fjava%2Fjoy-down%2Findex.html" target="_blank">用 Java 实现断点续传 (HTTP)</a></li>
<li><a href="https://links.jianshu.com/go?to=https%3A%2F%2Fwww.iteye.com%2Fblog%2Fhw1287789687-2188500" target="_blank">Content-disposition中Attachment和inline的区别</a></li>
<li><a href="https://links.jianshu.com/go?to=https%3A%2F%2Fdeveloper.mozilla.org%2Fzh-CN%2Fdocs%2FWeb%2FHTTP%2FHeaders%2FContent-Disposition" target="_blank">HTTP headers</a></li>
</ul>
</blockquote>
<h3>三、前面Html页面</h3>
<div class="_2Uzcx_"><button class="VJbwyy" type="button" aria-label="复制代码"><i aria-label="icon: copy" class="anticon anticon-copy"><svg viewBox="64 64 896 896" focusable="false" class="" data-icon="copy" width="1em" height="1em" fill="currentColor" aria-hidden="true"><path d="M832 64H296c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h496v688c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8V96c0-17.7-14.3-32-32-32zM704 192H192c-17.7 0-32 14.3-32 32v530.7c0 8.5 3.4 16.6 9.4 22.6l173.3 173.3c2.2 2.2 4.7 4 7.4 5.5v1.9h4.2c3.5 1.3 7.2 2 11 2H704c17.7 0 32-14.3 32-32V224c0-17.7-14.3-32-32-32zM350 856.2L263.9 770H350v86.2zM664 888H414V746c0-22.1-17.9-40-40-40H232V264h432v624z"></path></svg></i></button><pre class="line-numbers  language-xml"><code class="  language-xml"><span class="token doctype">&lt;!DOCTYPE html&gt;</span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>html</span> <span class="token attr-name">lang</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>en<span class="token punctuation">"</span></span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>head</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>meta</span> <span class="token attr-name">charset</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>UTF-8<span class="token punctuation">"</span></span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>title</span><span class="token punctuation">&gt;</span></span>操作视频<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>title</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>head</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>body</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">style</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>text-align: center; margin-top: 50px; <span class="token punctuation">"</span></span><span class="token punctuation">&gt;</span></span>

    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h2</span><span class="token punctuation">&gt;</span></span>操作视频<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h2</span><span class="token punctuation">&gt;</span></span>
    &lt;video width="75%" height=600" controls="controls" controlslist="nodownload"&gt;
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>source</span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>my_video_1<span class="token punctuation">"</span></span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>http://localhost:9070/api/v1/resource/file/video/small.mp4<span class="token punctuation">"</span></span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>video/ogg<span class="token punctuation">"</span></span><span class="token punctuation">/&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>source</span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>my_video_2<span class="token punctuation">"</span></span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>http://localhost:9070/api/v1/resource/file/video/small.mp4<span class="token punctuation">"</span></span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>video/mp4<span class="token punctuation">"</span></span><span class="token punctuation">/&gt;</span></span>
        Your browser does not support the video tag.
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>video</span><span class="token punctuation">&gt;</span></span>
   
   <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h2</span> <span class="token attr-name">style</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>color: red;<span class="token punctuation">"</span></span><span class="token punctuation">&gt;</span></span>该操作视频不存在或已经失效.<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h2</span><span class="token punctuation">&gt;</span></span>
 
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>body</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>html</span><span class="token punctuation">&gt;</span></span>
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre></div>
<h3>四、缓存文件定时删除任务</h3>
<div class="_2Uzcx_"><button class="VJbwyy" type="button" aria-label="复制代码"><i aria-label="icon: copy" class="anticon anticon-copy"><svg viewBox="64 64 896 896" focusable="false" class="" data-icon="copy" width="1em" height="1em" fill="currentColor" aria-hidden="true"><path d="M832 64H296c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h496v688c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8V96c0-17.7-14.3-32-32-32zM704 192H192c-17.7 0-32 14.3-32 32v530.7c0 8.5 3.4 16.6 9.4 22.6l173.3 173.3c2.2 2.2 4.7 4 7.4 5.5v1.9h4.2c3.5 1.3 7.2 2 11 2H704c17.7 0 32-14.3 32-32V224c0-17.7-14.3-32-32-32zM350 856.2L263.9 770H350v86.2zM664 888H414V746c0-22.1-17.9-40-40-40H232V264h432v624z"></path></svg></i></button><pre class="line-numbers  language-java"><code class="  language-java"><span class="token keyword">package</span> <span class="token namespace">com<span class="token punctuation">.</span>unnet<span class="token punctuation">.</span>yjs<span class="token punctuation">.</span>config</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>unnet<span class="token punctuation">.</span>yjs<span class="token punctuation">.</span>base</span><span class="token punctuation">.</span><span class="token class-name">ContainerProperties</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>unnet<span class="token punctuation">.</span>yjs<span class="token punctuation">.</span>entity</span><span class="token punctuation">.</span><span class="token class-name">Log</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>unnet<span class="token punctuation">.</span>yjs<span class="token punctuation">.</span>entity</span><span class="token punctuation">.</span><span class="token class-name">OssFileRecord</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>unnet<span class="token punctuation">.</span>yjs<span class="token punctuation">.</span>service</span><span class="token punctuation">.</span><span class="token class-name">OssFileRecordService</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>slf4j</span><span class="token punctuation">.</span><span class="token class-name">Logger</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>slf4j</span><span class="token punctuation">.</span><span class="token class-name">LoggerFactory</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>context<span class="token punctuation">.</span>annotation</span><span class="token punctuation">.</span><span class="token class-name">Configuration</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>scheduling<span class="token punctuation">.</span>annotation</span><span class="token punctuation">.</span><span class="token class-name">EnableScheduling</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>scheduling<span class="token punctuation">.</span>annotation</span><span class="token punctuation">.</span><span class="token class-name">Scheduled</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>stereotype</span><span class="token punctuation">.</span><span class="token class-name">Component</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token namespace">javax<span class="token punctuation">.</span>annotation</span><span class="token punctuation">.</span><span class="token class-name">Resource</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">java<span class="token punctuation">.</span>io</span><span class="token punctuation">.</span><span class="token class-name">File</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">java<span class="token punctuation">.</span>text</span><span class="token punctuation">.</span><span class="token class-name">DecimalFormat</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">java<span class="token punctuation">.</span>util</span><span class="token punctuation">.</span><span class="token class-name">ArrayList</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">java<span class="token punctuation">.</span>util</span><span class="token punctuation">.</span><span class="token class-name">List</span><span class="token punctuation">;</span>

<span class="token comment">/**
 * Email: love1208tt@foxmail.com
 * Copyright (c)  2019. missbe
 * @author lyg   19-7-10 下午7:48
 *
 *
 **/</span>
<span class="token annotation punctuation">@Component</span>
<span class="token annotation punctuation">@Configuration</span>
<span class="token annotation punctuation">@EnableScheduling</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">ScheduleTaskConfig</span> <span class="token punctuation">{</span>
    <span class="token keyword">private</span> <span class="token keyword">static</span> <span class="token keyword">final</span> <span class="token class-name">Logger</span> LOGGER <span class="token operator">=</span> <span class="token class-name">LoggerFactory</span><span class="token punctuation">.</span><span class="token function">getLogger</span><span class="token punctuation">(</span><span class="token class-name">ScheduleTaskConfig</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token annotation punctuation">@Resource</span>
    <span class="token keyword">private</span> <span class="token class-name">ContainerProperties</span> containerProperties<span class="token punctuation">;</span>
    <span class="token annotation punctuation">@Resource</span>
    <span class="token keyword">private</span> <span class="token class-name">OssFileRecordService</span> ossFileRecordService<span class="token punctuation">;</span>

    <span class="token annotation punctuation">@Scheduled</span><span class="token punctuation">(</span>cron <span class="token operator">=</span>  <span class="token string">"0 0 2 1/7 * ?"</span><span class="token punctuation">)</span>
<span class="token comment">//    @Scheduled(cron =  "0/40 * * * * ?")</span>
    <span class="token keyword">private</span> <span class="token keyword">void</span> <span class="token function">scheduleDeleteFile</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
        <span class="token class-name">Log</span> sysLog <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Log</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        sysLog<span class="token punctuation">.</span><span class="token function">setBrowser</span><span class="token punctuation">(</span><span class="token string">"Default"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        sysLog<span class="token punctuation">.</span><span class="token function">setUsername</span><span class="token punctuation">(</span><span class="token string">"OssFileTask"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        sysLog<span class="token punctuation">.</span><span class="token function">setType</span><span class="token punctuation">(</span><span class="token string">"OssFileTask"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        sysLog<span class="token punctuation">.</span><span class="token function">setTitle</span><span class="token punctuation">(</span><span class="token string">"OssFileTask"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">long</span> startTime <span class="token operator">=</span> <span class="token class-name">System</span><span class="token punctuation">.</span><span class="token function">currentTimeMillis</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        LOGGER<span class="token punctuation">.</span><span class="token function">info</span><span class="token punctuation">(</span><span class="token string">"开始定时删除缓存文件任务，控制文件夹【{}】大小."</span><span class="token punctuation">,</span>containerProperties<span class="token punctuation">.</span><span class="token function">getFileCacheLocation</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">long</span> folderSize <span class="token operator">=</span> <span class="token function">getFolderSize</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">long</span> gUnit <span class="token operator">=</span> <span class="token number">1073741824L</span><span class="token punctuation">;</span>
        <span class="token class-name">String</span> restrictSizeString <span class="token operator">=</span> containerProperties<span class="token punctuation">.</span><span class="token function">getRestrictSize</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">long</span> restrictSize <span class="token operator">=</span> <span class="token class-name">Long</span><span class="token punctuation">.</span><span class="token function">parseLong</span><span class="token punctuation">(</span>restrictSizeString<span class="token punctuation">)</span><span class="token punctuation">;</span>
        LOGGER<span class="token punctuation">.</span><span class="token function">info</span><span class="token punctuation">(</span><span class="token string">"文件夹：【{}】，大小：【{}】，限制大小为：【{}G】"</span><span class="token punctuation">,</span>containerProperties<span class="token punctuation">.</span><span class="token function">getFileCacheLocation</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span><span class="token function">formatFileSize</span><span class="token punctuation">(</span>folderSize<span class="token punctuation">)</span><span class="token punctuation">,</span>restrictSize<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">///如果超出限制进行清理</span>
        restrictSize <span class="token operator">=</span> restrictSize <span class="token operator">*</span> gUnit<span class="token punctuation">;</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span> restrictSize <span class="token operator">&lt;</span> folderSize<span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">OssFileRecord</span><span class="token punctuation">&gt;</span></span> ossFileRecords <span class="token operator">=</span> ossFileRecordService<span class="token punctuation">.</span><span class="token function">findAll</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">OssFileRecord</span><span class="token punctuation">&gt;</span></span> waitDeleteRecord <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">ArrayList</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token comment">////删除限制大小的一半内容</span>
            restrictSize <span class="token operator">=</span> restrictSize <span class="token operator">/</span> <span class="token number">2</span><span class="token punctuation">;</span>
            <span class="token keyword">long</span> totalWaitDeleteSize <span class="token operator">=</span> <span class="token number">0L</span><span class="token punctuation">;</span>
            <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token class-name">OssFileRecord</span> record <span class="token operator">:</span> ossFileRecords<span class="token punctuation">)</span> <span class="token punctuation">{</span>
                <span class="token keyword">if</span> <span class="token punctuation">(</span>totalWaitDeleteSize <span class="token operator">&lt;</span> restrictSize<span class="token punctuation">)</span> <span class="token punctuation">{</span>
                    waitDeleteRecord<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>record<span class="token punctuation">)</span><span class="token punctuation">;</span>
                    totalWaitDeleteSize <span class="token operator">+=</span> <span class="token class-name">Long</span><span class="token punctuation">.</span><span class="token function">parseLong</span><span class="token punctuation">(</span>record<span class="token punctuation">.</span><span class="token function">getFileLength</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token punctuation">}</span><span class="token keyword">else</span> <span class="token punctuation">{</span>
                    <span class="token keyword">break</span><span class="token punctuation">;</span>
                <span class="token punctuation">}</span><span class="token comment">///end if</span>
            <span class="token punctuation">}</span><span class="token comment">///end for</span>
            <span class="token class-name">File</span> waitDeleteFile<span class="token punctuation">;</span>
            <span class="token class-name">StringBuilder</span> builder <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">StringBuilder</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token class-name">OssFileRecord</span> record <span class="token operator">:</span> waitDeleteRecord<span class="token punctuation">)</span> <span class="token punctuation">{</span>
                waitDeleteFile <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">File</span><span class="token punctuation">(</span>containerProperties<span class="token punctuation">.</span><span class="token function">getFileCacheLocation</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">+</span> record<span class="token punctuation">.</span><span class="token function">getFileName</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token keyword">boolean</span> isDelete <span class="token operator">=</span> waitDeleteFile<span class="token punctuation">.</span><span class="token function">delete</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token keyword">if</span> <span class="token punctuation">(</span>isDelete<span class="token punctuation">)</span> <span class="token punctuation">{</span>
                    LOGGER<span class="token punctuation">.</span><span class="token function">info</span><span class="token punctuation">(</span><span class="token string">"文件【{}】删除成功."</span><span class="token punctuation">,</span>record<span class="token punctuation">)</span><span class="token punctuation">;</span>
                    <span class="token comment">///删除该条记录</span>
                    record<span class="token punctuation">.</span><span class="token function">deleteById</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token punctuation">}</span><span class="token keyword">else</span><span class="token punctuation">{</span>
                    builder<span class="token punctuation">.</span><span class="token function">append</span><span class="token punctuation">(</span>record<span class="token punctuation">)</span><span class="token punctuation">;</span>
                    LOGGER<span class="token punctuation">.</span><span class="token function">info</span><span class="token punctuation">(</span><span class="token string">"文件【{}】删除失败."</span><span class="token punctuation">,</span>record<span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token punctuation">}</span><span class="token comment">///end if</span>
            <span class="token punctuation">}</span>
            sysLog<span class="token punctuation">.</span><span class="token function">setException</span><span class="token punctuation">(</span>builder<span class="token punctuation">.</span><span class="token function">toString</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            LOGGER<span class="token punctuation">.</span><span class="token function">info</span><span class="token punctuation">(</span><span class="token string">"结束定时删除缓存文件任务，此次删除【{}】文件.文件夹剩余大小：{}"</span><span class="token punctuation">,</span><span class="token function">formatFileSize</span><span class="token punctuation">(</span>totalWaitDeleteSize<span class="token punctuation">)</span><span class="token punctuation">,</span><span class="token function">formatFileSize</span><span class="token punctuation">(</span><span class="token function">getFolderSize</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span><span class="token keyword">else</span> <span class="token punctuation">{</span>
            LOGGER<span class="token punctuation">.</span><span class="token function">info</span><span class="token punctuation">(</span><span class="token string">"结束定时删除缓存文件任务，文件夹【{}】未超过限定大小."</span><span class="token punctuation">,</span>containerProperties<span class="token punctuation">.</span><span class="token function">getFileCacheLocation</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        sysLog<span class="token punctuation">.</span><span class="token function">setUseTime</span><span class="token punctuation">(</span><span class="token class-name">System</span><span class="token punctuation">.</span><span class="token function">currentTimeMillis</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">-</span> startTime<span class="token punctuation">)</span><span class="token punctuation">;</span>
        sysLog<span class="token punctuation">.</span><span class="token function">setRemoteAddr</span><span class="token punctuation">(</span><span class="token string">"127.0.0.1"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        sysLog<span class="token punctuation">.</span><span class="token function">setRequestUri</span><span class="token punctuation">(</span><span class="token string">"/api/v1/resource/file/video"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        sysLog<span class="token punctuation">.</span><span class="token function">setClassMethod</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">getClass</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">getName</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        sysLog<span class="token punctuation">.</span><span class="token function">setHttpMethod</span><span class="token punctuation">(</span><span class="token string">"Native"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">///add sys log</span>
        sysLog<span class="token punctuation">.</span><span class="token function">insert</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token keyword">private</span> <span class="token keyword">long</span> <span class="token function">getFolderSize</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
        <span class="token class-name">String</span> folderPath <span class="token operator">=</span> containerProperties<span class="token punctuation">.</span><span class="token function">getFileCacheLocation</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">File</span> parentDir <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">File</span><span class="token punctuation">(</span>folderPath<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">!</span>parentDir<span class="token punctuation">.</span><span class="token function">exists</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token keyword">boolean</span> isMakeParentDir <span class="token operator">=</span> parentDir<span class="token punctuation">.</span><span class="token function">mkdirs</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">if</span><span class="token punctuation">(</span>isMakeParentDir<span class="token punctuation">)</span><span class="token punctuation">{</span>
                LOGGER<span class="token punctuation">.</span><span class="token function">info</span><span class="token punctuation">(</span><span class="token string">"创建文件夹{}成功."</span><span class="token punctuation">,</span>parentDir<span class="token punctuation">.</span><span class="token function">getAbsolutePath</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span><span class="token keyword">else</span> <span class="token punctuation">{</span>
                LOGGER<span class="token punctuation">.</span><span class="token function">error</span><span class="token punctuation">(</span><span class="token string">"创建文件夹{}失败."</span><span class="token punctuation">,</span>parentDir<span class="token punctuation">.</span><span class="token function">getAbsolutePath</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
        <span class="token punctuation">}</span><span class="token comment">//end if</span>
        <span class="token keyword">return</span> <span class="token function">getFileSize</span><span class="token punctuation">(</span>parentDir<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token comment">/**
     * 递归计算文件夹或文件占用大小
     * @param file 文件
     * @return 文件总大小
     */</span>
    <span class="token keyword">private</span> <span class="token keyword">long</span> <span class="token function">getFileSize</span><span class="token punctuation">(</span><span class="token class-name">File</span> file<span class="token punctuation">)</span><span class="token punctuation">{</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span>file<span class="token punctuation">.</span><span class="token function">isFile</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token keyword">return</span> file<span class="token punctuation">.</span><span class="token function">length</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token keyword">long</span> totalSize <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
        <span class="token class-name">File</span><span class="token punctuation">[</span><span class="token punctuation">]</span> listFiles <span class="token operator">=</span> file<span class="token punctuation">.</span><span class="token function">listFiles</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">assert</span> listFiles <span class="token operator">!=</span> <span class="token keyword">null</span><span class="token punctuation">;</span>
        <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token class-name">File</span> f <span class="token operator">:</span> listFiles<span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token keyword">if</span> <span class="token punctuation">(</span>f<span class="token punctuation">.</span><span class="token function">isDirectory</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
                totalSize <span class="token operator">+=</span> <span class="token function">getFileSize</span><span class="token punctuation">(</span>f<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span><span class="token keyword">else</span><span class="token punctuation">{</span>
                totalSize <span class="token operator">+=</span> f<span class="token punctuation">.</span><span class="token function">length</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
        <span class="token punctuation">}</span><span class="token comment">///end for</span>
        <span class="token keyword">return</span> totalSize<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token keyword">private</span>  <span class="token class-name">String</span> <span class="token function">formatFileSize</span><span class="token punctuation">(</span><span class="token keyword">long</span> fileByte<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token class-name">DecimalFormat</span> df <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">DecimalFormat</span><span class="token punctuation">(</span><span class="token string">"#.00"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">String</span> fileSizeFormat <span class="token operator">=</span> <span class="token string">""</span><span class="token punctuation">;</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span>fileByte <span class="token operator">&lt;</span> <span class="token number">1024</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            fileSizeFormat <span class="token operator">=</span> df<span class="token punctuation">.</span><span class="token function">format</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token keyword">double</span><span class="token punctuation">)</span> fileByte<span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token string">"B"</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token keyword">if</span> <span class="token punctuation">(</span>fileByte <span class="token operator">&lt;</span> <span class="token number">1048576</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            fileSizeFormat <span class="token operator">=</span> df<span class="token punctuation">.</span><span class="token function">format</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token keyword">double</span><span class="token punctuation">)</span> fileByte <span class="token operator">/</span> <span class="token number">1024</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token string">"K"</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token keyword">if</span> <span class="token punctuation">(</span>fileByte <span class="token operator">&lt;</span> <span class="token number">1073741824</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            fileSizeFormat <span class="token operator">=</span> df<span class="token punctuation">.</span><span class="token function">format</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token keyword">double</span><span class="token punctuation">)</span> fileByte <span class="token operator">/</span> <span class="token number">1048576</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token string">"M"</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{</span>
            fileSizeFormat <span class="token operator">=</span> df<span class="token punctuation">.</span><span class="token function">format</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token keyword">double</span><span class="token punctuation">)</span> fileByte <span class="token operator">/</span> <span class="token number">1073741824</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token string">"G"</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token keyword">return</span> fileSizeFormat<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

<span class="token punctuation">}</span>
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre></div>
<blockquote>
<p>ps:文件缓存在本地，设置缓存上界，当达到了阈值时进行删除文件操作，文件删除根据访问次数，每次文件访问记录访问历史，根据访问历史来进行清除；其它配置字段如下：</p>
</blockquote>
<div class="_2Uzcx_"><button class="VJbwyy" type="button" aria-label="复制代码"><i aria-label="icon: copy" class="anticon anticon-copy"><svg viewBox="64 64 896 896" focusable="false" class="" data-icon="copy" width="1em" height="1em" fill="currentColor" aria-hidden="true"><path d="M832 64H296c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h496v688c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8V96c0-17.7-14.3-32-32-32zM704 192H192c-17.7 0-32 14.3-32 32v530.7c0 8.5 3.4 16.6 9.4 22.6l173.3 173.3c2.2 2.2 4.7 4 7.4 5.5v1.9h4.2c3.5 1.3 7.2 2 11 2H704c17.7 0 32-14.3 32-32V224c0-17.7-14.3-32-32-32zM350 856.2L263.9 770H350v86.2zM664 888H414V746c0-22.1-17.9-40-40-40H232V264h432v624z"></path></svg></i></button><pre class="line-numbers  language-ruby"><code class="  language-ruby"><span class="token comment">###配置本地文件缓存位置-以/结尾【对象存储才会缓存到本地】</span>
ok<span class="token punctuation">.</span>resource<span class="token punctuation">.</span>file<span class="token punctuation">.</span>cache<span class="token punctuation">.</span>location<span class="token operator">=</span><span class="token operator">/</span>data<span class="token operator">/</span>oneclick<span class="token regex">/video/</span>

<span class="token comment">###配置本地视频缓存文件大小，默认5G；超过大小根据访问次数进行清理</span>
ok<span class="token punctuation">.</span>resource<span class="token punctuation">.</span>file<span class="token punctuation">.</span>cache<span class="token punctuation">.</span>restricted<span class="token punctuation">.</span>size<span class="token operator">=</span><span class="token number">5</span>
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span></span></code></pre></div>
<h3>五、功能实现图</h3>
<div class="image-package">
<div class="image-container" style="max-width: 700px; max-height: 689px; background-color: transparent;">
<div class="image-container-fill" style="padding-bottom: 47.85%;"></div>
<div class="image-view" data-width="1440" data-height="689"><img data-original-src="//upload-images.jianshu.io/upload_images/11736889-3445e784899b338a.png" data-original-width="1440" data-original-height="689" data-original-format="image/png" data-original-filesize="835334" data-image-index="0" style="cursor: zoom-in;" class="" src="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/11736889-3445e784899b338a.png"></div>
</div>
<div class="image-caption">image.png</div>
</div><br>
<div class="image-package">
<div class="image-container" style="max-width: 700px; max-height: 353px; background-color: transparent;">
<div class="image-container-fill" style="padding-bottom: 50.339999999999996%;"></div>
<div class="image-view" data-width="1490" data-height="750"><img data-original-src="//upload-images.jianshu.io/upload_images/11736889-ceb3093e7f9dd45e.png" data-original-width="1490" data-original-height="750" data-original-format="image/png" data-original-filesize="1218632" data-image-index="1" style="cursor: zoom-in;" class="" src="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/11736889-ceb3093e7f9dd45e.png"></div>
</div>
<div class="image-caption">image.png</div>
</div>
</article><div></div><div class="_1kCBjS"><div class="_18vaTa"><div class="_3BUZPB"><div class="_2Bo4Th" role="button" tabindex="-1" aria-label="给文章点赞"><i aria-label="ic-like" class="anticon"><svg width="1em" height="1em" fill="currentColor" aria-hidden="true" focusable="false" class=""><use xlink:href="#ic-like"></use></svg></i></div><span class="_1LOh_5" role="button" tabindex="-1" aria-label="查看点赞列表">31人点赞<i aria-label="icon: right" class="anticon anticon-right"><svg viewBox="64 64 896 896" focusable="false" class="" data-icon="right" width="1em" height="1em" fill="currentColor" aria-hidden="true"><path d="M765.7 486.8L314.9 134.7A7.97 7.97 0 0 0 302 141v77.3c0 4.9 2.3 9.6 6.1 12.6l360 281.1-360 281.1c-3.9 3-6.1 7.7-6.1 12.6V883c0 6.7 7.7 10.4 12.9 6.3l450.8-352.1a31.96 31.96 0 0 0 0-50.4z"></path></svg></i></span></div><div class="_3BUZPB"><div class="_2Bo4Th" role="button" tabindex="-1"><i aria-label="ic-dislike" class="anticon"><svg width="1em" height="1em" fill="currentColor" aria-hidden="true" focusable="false" class=""><use xlink:href="#ic-dislike"></use></svg></i></div></div></div><div class="_18vaTa"><a class="_3BUZPB _1x1ok9 _1OhGeD" href="https://www.jianshu.com/nb/38440121" target="_blank" rel="noopener noreferrer"><i aria-label="ic-notebook" class="anticon"><svg width="1em" height="1em" fill="currentColor" aria-hidden="true" focusable="false" class=""><use xlink:href="#ic-notebook"></use></svg></i><span>原创文章</span></a><div class="_3BUZPB ant-dropdown-trigger"><div class="_2Bo4Th"><i aria-label="ic-others" class="anticon"><svg width="1em" height="1em" fill="currentColor" aria-hidden="true" focusable="false" class=""><use xlink:href="#ic-others"></use></svg></i></div></div></div></div><div class="_19DgIp" style="margin-top:24px;margin-bottom:24px"></div><div class="_13lIbp"><div class="_191KSt">"小礼物走一走，来简书关注我"</div><button type="button" class="_1OyPqC _3Mi9q9 _2WY0RL _1YbC5u"><span>赞赏支持</span></button><span class="_3zdmIj">还没有人赞赏，支持一下</span></div><div class="d0hShY"><a class="_1OhGeD" href="https://www.jianshu.com/u/1331c2256306" target="_blank" rel="noopener noreferrer"><img class="_27NmgV" src="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/b7c8de10-60ca-437e-81da-5ab169cdbb45(2)" alt="  "></a><div class="Uz-vZq"><div class="Cqpr1X"><a class="HC3FFO _1OhGeD" href="https://www.jianshu.com/u/1331c2256306" title="依然慢节奏" target="_blank" rel="noopener noreferrer">依然慢节奏</a><span class="_2WEj6j" title=""></span></div><div class="lJvI3S"><span>总资产31 (约2.66元)</span><span>共写了2.7W字</span><span>获得178个赞</span><span>共45个粉丝</span></div></div><button data-locale="zh-CN" type="button" class="_1OyPqC _3Mi9q9"><span>关注</span></button></div></section><section class="sFiE8U" aria-label="google-ad"><ins class="adsbygoogle" style="display:inline-block;width:730px;height:114px" data-ad-client="ca-pub-3077285224019295" data-ad-slot="2979144022" data-adsbygoogle-status="done"><ins id="aswift_0_expand" style="display:inline-table;border:none;height:114px;margin:0;padding:0;position:relative;visibility:visible;width:730px;background-color:transparent;"><ins id="aswift_0_anchor" style="display:block;border:none;height:114px;margin:0;padding:0;position:relative;visibility:visible;width:730px;background-color:transparent;"><iframe width="730" height="114" frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" allowfullscreen="true" onload="var i=this.id,s=window.google_iframe_oncopy,H=s&amp;&amp;s.handlers,h=H&amp;&amp;H[i],w=this.contentWindow,d;try{d=w.document}catch(e){}if(h&amp;&amp;d&amp;&amp;(!d.body||!d.body.firstChild)){if(h.call){setTimeout(h,0)}else if(h.match){try{h=s.upd(h,i)}catch(e){}w.location.replace(h)}}" id="aswift_0" name="aswift_0" style="left:0;position:absolute;top:0;border:0px;width:730px;height:114px;" src="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/saved_resource(3).html"></iframe></ins></ins></ins><script type="text/javascript" src="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/f(10).txt" async=""></script></section><div id="note-page-comment"><section class="ouvJEz"><div class="_26JdYM"><img class="_3LHFA-" src="https://www.jianshu.com/p/c449dec43099" alt=""><div class="_3GKFE3"><textarea class="_1u_H4i" placeholder="写下你的评论..."></textarea><div></div></div></div><div class="_2lR7N6" style="display: none;"><div class="_17_lFi"><div class="_3k5vgx"></div><div><div class="U36Th9"></div><div class="_9aTHBB"></div></div></div><div class="_1Lq8tt"></div><div class="_1Lq8tt _1muh0x"></div><div class="_3Pu4Wf"><i aria-label="ic-like" class="anticon"><svg width="1em" height="1em" fill="currentColor" aria-hidden="true" focusable="false" class=""><use xlink:href="#ic-like"></use></svg></i><div class="_1mcOnW"></div><i aria-label="ic-reply" class="anticon"><svg width="1em" height="1em" fill="currentColor" aria-hidden="true" focusable="false" class=""><use xlink:href="#ic-reply"></use></svg></i><div class="_1mcOnW"></div></div></div><h3 class="QxT4hD"><div class="_10KzV0"><span>全部评论</span><span class="_2R7vBo">0</span><span class="_1DVmvZ" role="checkbox" tabindex="0" aria-label="只看作者" aria-checked="false">只看作者</span></div><div class="_2zSaYx"><div class="_1ekjko _1BIpxf" role="button" tabindex="-1">按时间倒序</div><div class="_1ekjko" role="button" tabindex="-1">按时间正序</div></div></h3><div class="_2lR7N6" style="display: none;"><div class="_17_lFi"><div class="_3k5vgx"></div><div><div class="U36Th9"></div><div class="_9aTHBB"></div></div></div><div class="_1Lq8tt"></div><div class="_1Lq8tt _1muh0x"></div><div class="_3Pu4Wf"><i aria-label="ic-like" class="anticon"><svg width="1em" height="1em" fill="currentColor" aria-hidden="true" focusable="false" class=""><use xlink:href="#ic-like"></use></svg></i><div class="_1mcOnW"></div><i aria-label="ic-reply" class="anticon"><svg width="1em" height="1em" fill="currentColor" aria-hidden="true" focusable="false" class=""><use xlink:href="#ic-reply"></use></svg></i><div class="_1mcOnW"></div></div></div></section></div><section class="ouvJEz"><h3 class="QxT4hD"><span>被以下专题收入，发现更多相似内容</span></h3><div class="_2Nttfz"><a class="_3s5t0Q _1OhGeD" href="https://www.jianshu.com/c/cdb58b2cbddb" target="_blank" rel="noopener noreferrer"><img class="_2vEwGY" src="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/crop1559610466044.jpg" alt=""><span class="_2-Djqu">springb...</span></a><a class="_3s5t0Q _1OhGeD" href="https://www.jianshu.com/c/483100c95de9" target="_blank" rel="noopener noreferrer"><img class="_2vEwGY" src="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/crop1539784555411.jpg" alt=""><span class="_2-Djqu">JAVA</span></a><a class="_3s5t0Q _1OhGeD" href="https://www.jianshu.com/c/2f1133f6ece6" target="_blank" rel="noopener noreferrer"><img class="_2vEwGY" src="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/crop1571926847128.jpg" alt=""><span class="_2-Djqu">springboot</span></a><a class="_3s5t0Q _1OhGeD" href="https://www.jianshu.com/c/e400f6f6bdb3" target="_blank" rel="noopener noreferrer"><img class="_2vEwGY" src="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/crop1573911834729.jpg" alt=""><span class="_2-Djqu">啦啦啦啦啦！</span></a><a class="_3s5t0Q _1OhGeD" href="https://www.jianshu.com/c/bfd928ba580b" target="_blank" rel="noopener noreferrer"><img class="_2vEwGY" src="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/呵呵.jpg" alt=""><span class="_2-Djqu">技术总结</span></a><a class="_3s5t0Q _1OhGeD" href="https://www.jianshu.com/c/95ff6e3ae7cf" target="_blank" rel="noopener noreferrer"><img class="_2vEwGY" src="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/Capture001.png" alt=""><span class="_2-Djqu">Spring ...</span></a><a class="_3s5t0Q _1OhGeD" href="https://www.jianshu.com/c/05c482ca551f" target="_blank" rel="noopener noreferrer"><img class="_2vEwGY" src="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/timg.jpg" alt=""><span class="_2-Djqu">java分布式</span></a></div><div class="_19DgIp" style="margin-top: 32px; margin-bottom: 32px;"></div><h3 class="QxT4hD"><span>推荐阅读</span><a class="_29KFEa _1OhGeD" href="https://www.jianshu.com/" target="_blank" rel="noopener noreferrer">更多精彩内容<i aria-label="ic-right" class="anticon"><svg width="1em" height="1em" fill="currentColor" aria-hidden="true" focusable="false" class=""><use xlink:href="#ic-right"></use></svg></i></a></h3><ul class="_1iTR78"><li class="_11jppn"><div class="JB6qEE"><div class="em6wEs" title="面试题" role="heading" aria-level="4"><a class="_2voXH8 _1OhGeD" href="https://www.jianshu.com/p/971865470673" target="_blank" rel="noopener noreferrer">面试题</a></div><div class="_3fvgn4">Swift1&gt; Swift和OC的区别1.1&gt; Swift没有地址/指针的概念1.2&gt; 泛型1.3&gt; 类型严谨 对...</div><div class="_1pJt6F"><a class="_3IWz1q _1OhGeD" href="https://www.jianshu.com/u/8626d3f52ac7" target="_blank" rel="noopener noreferrer"><img class="_34VC_H" src="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/321970238233" alt=""><span class="_3tPsL6">cosWriter</span></a><span class="_31hjBO">阅读<!-- --> <!-- -->4,461</span><span class="_31hjBO">评论<!-- --> <!-- -->1</span><span class="_31hjBO">赞<!-- --> <!-- -->16</span></div></div></li><li class="_11jppn"><div class="JB6qEE"><div class="em6wEs" title=" NSURLSession用法示例及断点续传视频的实现" role="heading" aria-level="4"><a class="_2voXH8 _1OhGeD" href="https://www.jianshu.com/p/bdf217565c6a" target="_blank" rel="noopener noreferrer"> NSURLSession用法示例及断点续传视频的实现</a></div><div class="_3fvgn4">原文链接：http://blog.csdn.net/mumubumaopao/article/details/52...</div><div class="_1pJt6F"><a class="_3IWz1q _1OhGeD" href="https://www.jianshu.com/u/55b7b3391bb7" target="_blank" rel="noopener noreferrer"><img class="_34VC_H" src="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/c7ab294c514f.jpeg" alt=""><span class="_3tPsL6">吃大米的小蚂蚁</span></a><span class="_31hjBO">阅读<!-- --> <!-- -->246</span><span class="_31hjBO">评论<!-- --> <!-- -->0</span><span class="_31hjBO">赞<!-- --> <!-- -->5</span></div></div><a class="_10MMAm _1OhGeD" href="https://www.jianshu.com/p/bdf217565c6a" target="_blank" rel="noopener noreferrer"><img class="_3zGDUj" src="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/1232108-3d73fc5b4545026e.gif" alt=""></a></li><li class="_11jppn"><div class="JB6qEE"><div class="em6wEs" title="图解：HTTP 范围请求，助力断点续传、多线程下载的核心原理" role="heading" aria-level="4"><a class="_2voXH8 _1OhGeD" href="https://www.jianshu.com/p/d329175411b1" target="_blank" rel="noopener noreferrer">图解：HTTP 范围请求，助力断点续传、多线程下载的核心原理</a></div><div class="_3fvgn4">题图：by Charles Loyer 一、序 Hi，大家好，我是承香墨影！ HTTP 协议在网络知识中占据了重要...</div><div class="_1pJt6F"><a class="_3IWz1q _1OhGeD" href="https://www.jianshu.com/u/41f8d148d1f4" target="_blank" rel="noopener noreferrer"><img class="_34VC_H" src="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/54f7d664-11c3-4d70-bbdc-ec797968107d.png" alt=""><span class="_3tPsL6">承香墨影</span></a><span class="_31hjBO">阅读<!-- --> <!-- -->872</span><span class="_31hjBO">评论<!-- --> <!-- -->0</span><span class="_31hjBO">赞<!-- --> <!-- -->15</span></div></div></li><li class="_11jppn"><div class="JB6qEE"><div class="em6wEs" title="☆" role="heading" aria-level="4"><a class="_2voXH8 _1OhGeD" href="https://www.jianshu.com/p/e0cb9961db20" target="_blank" rel="noopener noreferrer">☆</a></div><div class="_3fvgn4"></div><div class="_1pJt6F"><a class="_3IWz1q _1OhGeD" href="https://www.jianshu.com/u/e9b5562e5e3c" target="_blank" rel="noopener noreferrer"><img class="_34VC_H" src="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/ac6f81134009.jpeg" alt=""><span class="_3tPsL6">大雪是也</span></a><span class="_31hjBO">阅读<!-- --> <!-- -->16</span><span class="_31hjBO">评论<!-- --> <!-- -->0</span><span class="_31hjBO">赞<!-- --> <!-- -->0</span></div></div><a class="_10MMAm _1OhGeD" href="https://www.jianshu.com/p/e0cb9961db20" target="_blank" rel="noopener noreferrer"><img class="_3zGDUj" src="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/2623658-b320d644ccda3634.png" alt=""></a></li><li class="_11jppn"><div class="JB6qEE"><div class="em6wEs" title="文字的艰辛" role="heading" aria-level="4"><a class="_2voXH8 _1OhGeD" href="https://www.jianshu.com/p/e8f0437a1110" target="_blank" rel="noopener noreferrer">文字的艰辛</a></div><div class="_3fvgn4">最近几天灵感枯竭，再也写不出富有灵动的文字。每天把心思都放在了窘迫的生活里面，还有什么精力去抒发情感呢。日子过的水...</div><div class="_1pJt6F"><a class="_3IWz1q _1OhGeD" href="https://www.jianshu.com/u/36fb885ca0b6" target="_blank" rel="noopener noreferrer"><img class="_34VC_H" src="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/e941708b-4ab8-438b-bc20-9d58fc5bffb7.jpg" alt=""><span class="_3tPsL6">巧手妙语</span></a><span class="_31hjBO">阅读<!-- --> <!-- -->409</span><span class="_31hjBO">评论<!-- --> <!-- -->6</span><span class="_31hjBO">赞<!-- --> <!-- -->15</span></div></div></li></ul></section></div><aside class="_2OwGUo"><section class="sFiE8U" aria-label="google-ad"><ins class="adsbygoogle" style="display:inline-block;width:260px;height:173px" data-ad-client="ca-pub-3077285224019295" data-ad-slot="2221979015" data-adsbygoogle-status="done"><ins id="aswift_1_expand" style="display:inline-table;border:none;height:173px;margin:0;padding:0;position:relative;visibility:visible;width:260px;background-color:transparent;"><ins id="aswift_1_anchor" style="display:block;border:none;height:173px;margin:0;padding:0;position:relative;visibility:visible;width:260px;background-color:transparent;"><iframe width="260" height="173" frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" allowfullscreen="true" onload="var i=this.id,s=window.google_iframe_oncopy,H=s&amp;&amp;s.handlers,h=H&amp;&amp;H[i],w=this.contentWindow,d;try{d=w.document}catch(e){}if(h&amp;&amp;d&amp;&amp;(!d.body||!d.body.firstChild)){if(h.call){setTimeout(h,0)}else if(h.match){try{h=s.upd(h,i)}catch(e){}w.location.replace(h)}}" id="aswift_1" name="aswift_1" style="left:0;position:absolute;top:0;border:0px;width:260px;height:173px;" src="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/saved_resource(4).html"></iframe></ins></ins></ins><script type="text/javascript" src="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/f(10).txt" async=""></script></section><section class="_3Z3nHf"><div class="_3Oo-T1"><a class="_1OhGeD" href="https://www.jianshu.com/u/1331c2256306" target="_blank" rel="noopener noreferrer"><img class="_3T9iJQ" src="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/b7c8de10-60ca-437e-81da-5ab169cdbb45(3)" alt=""></a><div class="_32ZTTG"><div class="_2O0T_w"><div class="_2v-h3G"><span class="_2vh4fr" title="依然慢节奏"><a class="_1OhGeD" href="https://www.jianshu.com/u/1331c2256306" target="_blank" rel="noopener noreferrer">依然慢节奏</a></span></div><button data-locale="zh-CN" type="button" class="tzrf9N _1OyPqC _3Mi9q9 _34692-"><span>关注</span></button></div><div class="_1pXc22">总资产31 (约2.66元)</div></div></div><div class="_19DgIp"></div><div class="_26Hhi2" role="listitem"><div class="_3TNGId" title="final,static,this,super 关键字总结"><a class="_2ER8Tt _1OhGeD" href="https://www.jianshu.com/p/78dc726a2bce" target="_blank" rel="noopener noreferrer">final,static,this,super 关键字总结</a></div><div class="DfvGP9">阅读 13</div></div><div class="_26Hhi2" role="listitem"><div class="_3TNGId" title="正确使用 equals 方法避免产生空指针异常"><a class="_2ER8Tt _1OhGeD" href="https://www.jianshu.com/p/306de20dd228" target="_blank" rel="noopener noreferrer">正确使用 equals 方法避免产生空指针异常</a></div><div class="DfvGP9">阅读 22</div></div><div class="_26Hhi2" role="listitem"><div class="_3TNGId" title="Collections 工具类和 Arrays 工具类常见方法"><a class="_2ER8Tt _1OhGeD" href="https://www.jianshu.com/p/ec1584b4de1f" target="_blank" rel="noopener noreferrer">Collections 工具类和 Arrays 工具类常见方法</a></div><div class="DfvGP9">阅读 8</div></div></section><div><div class="" style=""><section class="_3Z3nHf"><h3 class="QHRnq8 QxT4hD"><span>推荐阅读</span></h3><div class="cuOxAY" role="listitem"><div class="_3L5YSq" title="面试官：给我讲一下分库分表方案"><a class="_1-HJSV _1OhGeD" href="https://www.jianshu.com/p/bf27be3fd448" target="_blank" rel="noopener noreferrer">面试官：给我讲一下分库分表方案</a></div><div class="_19haGh">阅读 6,537</div></div><div class="cuOxAY" role="listitem"><div class="_3L5YSq" title="8种最坑的SQL错误用法，第一个就很坑？"><a class="_1-HJSV _1OhGeD" href="https://www.jianshu.com/p/a344836b3532" target="_blank" rel="noopener noreferrer">8种最坑的SQL错误用法，第一个就很坑？</a></div><div class="_19haGh">阅读 4,443</div></div><div class="cuOxAY" role="listitem"><div class="_3L5YSq" title="MySQL 每秒 570000 的写入，如何实现？"><a class="_1-HJSV _1OhGeD" href="https://www.jianshu.com/p/9bf3d0dfafdc" target="_blank" rel="noopener noreferrer">MySQL 每秒 570000 的写入，如何实现？</a></div><div class="_19haGh">阅读 1,835</div></div><div class="cuOxAY" role="listitem"><div class="_3L5YSq" title="阿里巴巴为什么能抗住90秒100亿？看完这篇你就明白了！"><a class="_1-HJSV _1OhGeD" href="https://www.jianshu.com/p/9f985bbc9c70" target="_blank" rel="noopener noreferrer">阿里巴巴为什么能抗住90秒100亿？看完这篇你就明白了！</a></div><div class="_19haGh">阅读 25,884</div></div><div class="cuOxAY" role="listitem"><div class="_3L5YSq" title="冒着被开除的风险也要给你们看的 Spring Cloud 入门总结"><a class="_1-HJSV _1OhGeD" href="https://www.jianshu.com/p/b6f5172d8b27" target="_blank" rel="noopener noreferrer">冒着被开除的风险也要给你们看的 Spring Cloud 入门总结</a></div><div class="_19haGh">阅读 4,947</div></div></section><section class="sFiE8U" aria-label="google-ad"><ins class="adsbygoogle" style="display:inline-block;width:260px;height:173px" data-ad-client="ca-pub-3077285224019295" data-ad-slot="1970871612" data-adsbygoogle-status="done"><ins id="aswift_2_expand" style="display:inline-table;border:none;height:173px;margin:0;padding:0;position:relative;visibility:visible;width:260px;background-color:transparent;"><ins id="aswift_2_anchor" style="display:block;border:none;height:173px;margin:0;padding:0;position:relative;visibility:visible;width:260px;background-color:transparent;"><iframe width="260" height="173" frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" allowfullscreen="true" onload="var i=this.id,s=window.google_iframe_oncopy,H=s&amp;&amp;s.handlers,h=H&amp;&amp;H[i],w=this.contentWindow,d;try{d=w.document}catch(e){}if(h&amp;&amp;d&amp;&amp;(!d.body||!d.body.firstChild)){if(h.call){setTimeout(h,0)}else if(h.match){try{h=s.upd(h,i)}catch(e){}w.location.replace(h)}}" id="aswift_2" name="aswift_2" style="left:0;position:absolute;top:0;border:0px;width:260px;height:173px;" src="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/saved_resource(5).html"></iframe></ins></ins></ins><script type="text/javascript" src="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/f(10).txt" async=""></script></section></div></div></aside><div class="ant-back-top"><div class="_3MyrRP" role="button" tabindex="-1" aria-label="回到顶部"><i aria-label="icon: caret-up" class="anticon anticon-caret-up"><svg viewBox="0 0 1024 1024" focusable="false" class="" data-icon="caret-up" width="1em" height="1em" fill="currentColor" aria-hidden="true"><path d="M858.9 689L530.5 308.2c-9.4-10.9-27.5-10.9-37 0L165.1 689c-12.2 14.2-1.2 35 18.5 35h656.8c19.7 0 30.7-20.8 18.5-35z"></path></svg></i></div></div></div></div><footer style="width:100%"><div class="_2xr8G8"><div class="_1Jdfvb"><div class="TDvCqd"><textarea class="W2TSX_" placeholder="写下你的评论..."></textarea></div><div class="-pXE92"><div class="_3nj4GN" role="button" tabindex="0" aria-label="添加评论"><i aria-label="ic-reply" class="anticon"><svg width="1em" height="1em" fill="currentColor" aria-hidden="true" focusable="false" class=""><use xlink:href="#ic-reply"></use></svg></i><span>评论<!-- -->0</span></div><div class="_3nj4GN" role="button" tabindex="0" aria-label="给文章点赞"><i aria-label="ic-like" class="anticon"><svg width="1em" height="1em" fill="currentColor" aria-hidden="true" focusable="false" class=""><use xlink:href="#ic-like"></use></svg></i><span>赞<!-- -->31</span></div><div class="_3nj4GN ant-dropdown-trigger" role="button" tabindex="0" aria-label="更多操作"><i aria-label="ic-others" class="anticon"><svg width="1em" height="1em" fill="currentColor" aria-hidden="true" focusable="false" class=""><use xlink:href="#ic-others"></use></svg></i></div></div></div></div><div class="_1LI0En" style="height: 56px;"></div></footer><div class="_3Pnjry"><div class="_1pUUKr"><div class="_2VdqdF" role="button" tabindex="-1" aria-label="给文章点赞"><i aria-label="ic-like" class="anticon"><svg width="1em" height="1em" fill="currentColor" aria-hidden="true" focusable="false" class=""><use xlink:href="#ic-like"></use></svg></i></div><div class="P63n6G"><div class="_2LKTFF"><span class="_1GPnWJ" role="button" tabindex="-1" aria-label="查看点赞列表">31<!-- -->赞</span><span class="_1GPnWJ">32<!-- -->赞</span></div></div></div><div class="_1pUUKr"><div class="_2VdqdF" role="button" tabindex="-1" aria-label="赞赏作者"><i aria-label="ic-shang" class="anticon"><svg width="1em" height="1em" fill="currentColor" aria-hidden="true" focusable="false" class=""><use xlink:href="#ic-shang"></use></svg></i></div><div class="P63n6G" role="button" tabindex="-1" aria-label="查看赞赏列表">赞赏</div></div></div></div><script async="" src="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/hm.js"></script><script async="" src="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/analytics.js"></script><script id="__NEXT_DATA__" type="application/json">{"dataManager":"[]","props":{"isServer":true,"initialState":{"global":{"fontType":"black","locale":"zh-CN","readMode":"day","seoList":[{"comments_count":1,"public_abbr":"Swift1\u003e Swift和OC的区别1.1\u003e Swift没有地址/指针的概念1.2\u003e 泛型1.3\u003e 类型严谨 对...","share_image_url":"","slug":"971865470673","user":{"id":2970841,"nickname":"cosWriter","slug":"8626d3f52ac7","avatar":"https://upload.jianshu.io/users/upload_avatars/2970841/321970238233"},"likes_count":16,"title":"面试题","id":28650614,"views_count":4461},{"comments_count":0,"public_abbr":"原文链接：http://blog.csdn.net/mumubumaopao/article/details/52...","share_image_url":"http://upload-images.jianshu.io/upload_images/1232108-3d73fc5b4545026e.gif","slug":"bdf217565c6a","user":{"id":1232108,"nickname":"吃大米的小蚂蚁","slug":"55b7b3391bb7","avatar":"https://upload.jianshu.io/users/upload_avatars/1232108/c7ab294c514f.jpeg"},"likes_count":5,"title":" NSURLSession用法示例及断点续传视频的实现","id":5132806,"views_count":246},{"comments_count":0,"public_abbr":"题图：by Charles Loyer 一、序 Hi，大家好，我是承香墨影！ HTTP 协议在网络知识中占据了重要...","share_image_url":"","slug":"d329175411b1","user":{"id":1420036,"nickname":"承香墨影","slug":"41f8d148d1f4","avatar":"https://upload.jianshu.io/users/upload_avatars/1420036/54f7d664-11c3-4d70-bbdc-ec797968107d.png"},"likes_count":15,"title":"图解：HTTP 范围请求，助力断点续传、多线程下载的核心原理","id":31249849,"views_count":872},{"comments_count":0,"public_abbr":"","share_image_url":"http://upload-images.jianshu.io/upload_images/2623658-b320d644ccda3634.png","slug":"e0cb9961db20","user":{"id":2623658,"nickname":"大雪是也","slug":"e9b5562e5e3c","avatar":"https://upload.jianshu.io/users/upload_avatars/2623658/ac6f81134009.jpeg"},"likes_count":0,"title":"☆","id":7273145,"views_count":16},{"comments_count":6,"public_abbr":"最近几天灵感枯竭，再也写不出富有灵动的文字。每天把心思都放在了窘迫的生活里面，还有什么精力去抒发情感呢。日子过的水...","share_image_url":"","slug":"e8f0437a1110","user":{"id":2197446,"nickname":"巧手妙语","slug":"36fb885ca0b6","avatar":"https://upload.jianshu.io/users/upload_avatars/2197446/e941708b-4ab8-438b-bc20-9d58fc5bffb7.jpg"},"likes_count":15,"title":"文字的艰辛","id":45211136,"views_count":409}],"done":false,"$ua":{"value":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36","isIE11":false,"earlyIE":null,"chrome":"79.0","firefox":null,"safari":null,"isMac":true},"$diamondRate":{"displayable":false,"rate":0},"$modal":{"ContributeModal":false,"RewardListModal":false,"PayModal":false,"CollectionModal":false,"LikeListModal":false,"ReportModal":false,"QRCodeShareModal":false,"BookCatalogModal":false,"RewardModal":false}},"note":{"data":{"is_author":false,"last_updated_at":1574259419,"public_title":"SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放","purchased":false,"liked_note":false,"comments_count":0,"free_content":"\u003ch4\u003e一、功能目的\u003c/h4\u003e\n\u003cp\u003eSpringBoot 实现Http分片下载断点续传，从而实现H5页面的大视频播放问题，实现渐进式播放，每次只播放需要播放的内容就可以了，不需要加载整个文件到内存中；\u003c/p\u003e\n\u003ch3\u003e二、Http分片下载断点续传实现\u003c/h3\u003e\n\u003cpre\u003e\u003ccode\u003epackage com.unnet.yjs.controller.api.v1;\n\nimport com.unnet.yjs.annotation.HttpMethod;\nimport com.unnet.yjs.base.ContainerProperties;\nimport com.unnet.yjs.entity.OssFileRecord;\nimport com.unnet.yjs.service.OssFileRecordService;\nimport com.unnet.yjs.util.IOssOperation;\nimport com.xiaoleilu.hutool.util.StrUtil;\nimport io.swagger.annotations.Api;\nimport io.swagger.annotations.ApiImplicitParam;\nimport io.swagger.annotations.ApiImplicitParams;\nimport io.swagger.annotations.ApiOperation;\nimport org.apache.catalina.connector.ClientAbortException;\nimport org.apache.tomcat.util.http.fileupload.IOUtils;\nimport org.slf4j.Logger;\nimport org.slf4j.LoggerFactory;\nimport org.springframework.beans.factory.annotation.Autowired;\nimport org.springframework.beans.factory.annotation.Qualifier;\nimport org.springframework.core.io.InputStreamResource;\nimport org.springframework.http.HttpHeaders;\nimport org.springframework.http.HttpStatus;\nimport org.springframework.http.MediaType;\nimport org.springframework.http.ResponseEntity;\nimport org.springframework.web.bind.annotation.*;\n\nimport javax.annotation.Resource;\nimport javax.servlet.http.HttpServletRequest;\nimport javax.servlet.http.HttpServletResponse;\nimport java.io.*;\nimport java.nio.charset.StandardCharsets;\nimport java.util.Objects;\n\n/**\n * Email: love1208tt@foxmail.com\n * Copyright (c)  2019. missbe\n * @author lyg   19-7-29 下午9:21\n *\n *\n **/\n@RestController\n@Api(tags = \"OssStreamConvertController\", description = \"文件上传控制器\")\n@RequestMapping(\"/api/v1/resource/file/\")\npublic class OssStreamConvertController {\n    private static final Logger LOGGER = LoggerFactory.getLogger(OssStreamConvertController.class);\n    @Resource\n    private ContainerProperties containerProperties;\n\n    @Autowired\n    @Qualifier(\"paasOssTool\")\n    private IOssOperation paasOssTool;\n    @Autowired\n    @Qualifier(\"minIoOssTool\")\n    private IOssOperation minIoOssTool;\n\n    @Resource\n    private OssFileRecordService ossFileRecordService;\n\n\n    /**\n     * 对象存储中转请求链接-根据文件名字请求对象存储的文件流\n     *\n     * @param fileName 文件名称\n     */\n    @GetMapping(\"video/{fileName}\")\n    @ApiOperation(value = \"对象存储文件流中转接口\", httpMethod = HttpMethod.GET)\n    @ApiImplicitParams({\n            @ApiImplicitParam(name = \"fileName\", value = \"文件名称\", paramType = \"path\")\n    })\n    public void videoPlayer(@PathVariable(value = \"fileName\") String fileName, HttpServletRequest request,HttpServletResponse response) throws IOException {\n        if(paasOssTool == null || minIoOssTool == null){\n            OutputStream out = response.getOutputStream();\n            out.write((\"OSS文件服务器配置出现问题,请修复后重试.\").getBytes());\n            out.flush();\n            out.close();\n            return;\n        }\n\n        ///是否开启本地缓存视频mp4文件\n        String filePath = containerProperties.getFileCacheLocation() + fileName;\n        File file = new File(filePath);\n        File parentDir = file.getParentFile();\n        if (!parentDir.exists()) {\n           boolean isMakeParentDir = parentDir.mkdirs();\n           if(isMakeParentDir){\n               LOGGER.info(\"创建文件夹{}成功.\",parentDir.getAbsolutePath());\n           }else {\n               LOGGER.error(\"创建文件夹{}失败.\",parentDir.getAbsolutePath());\n           }\n        }//end if\n        if (!file.exists()) {\n            ///本地文件不存在,从OSS下载到本地\n            boolean isMakeNewFile = file.createNewFile();\n            if(isMakeNewFile){\n                LOGGER.info(\"创建文件{}成功.\",file.getAbsolutePath());\n            }else {\n                LOGGER.error(\"创建文件{}失败.\",file.getAbsolutePath());\n            }\n            ByteArrayOutputStream baos = new ByteArrayOutputStream();\n            InputStream is = null;\n            try {\n                if (StrUtil.equalsIgnoreCase(containerProperties.getFileUploadType(), \"myOss\")) {\n                    is = minIoOssTool.load(fileName);\n                }\n                if (StrUtil.equalsIgnoreCase(containerProperties.getFileUploadType(), \"paas\")) {\n                    is = paasOssTool.load(fileName);\n                }\n            } catch (Exception e) {\n                e.printStackTrace();\n                e.printStackTrace();\n                LOGGER.error(\"对象存储加载文件失败,msg:\"+e.getLocalizedMessage());\n                OutputStream out = response.getOutputStream();\n                out.write((\"对象存储加载文件失败,msg:\"+e.getLocalizedMessage()).getBytes());\n                out.flush();\n                out.close();\n                return;\n            }\n            ////判断流不为空\n            Objects.requireNonNull(is);\n\n            BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file));\n            byte[] buffer = new byte[4096];\n            int length;\n            while ((length = is.read(buffer)) != -1) {\n                bos.write(buffer, 0, length);\n            }\n            bos.flush();\n            bos.close();\n        }///end if\n        LOGGER.info(\"文件：{}，总长度：{}\",file.getName(),file.length());\n        ///对文件执行分块\n        fileChunkDownload(filePath,request,response);\n        /////添加文件访问记录\n        OssFileRecord ossFileRecord = ossFileRecordService.findByFileName(fileName);\n        if (Objects.nonNull(ossFileRecord)) {\n            ossFileRecord.setFileLength(String.valueOf(file.length()));\n            ossFileRecord.setVisitCount(ossFileRecord.getVisitCount() + 1);\n        }else{\n            ossFileRecord = new OssFileRecord();\n            ossFileRecord.setFileName(fileName);\n            ossFileRecord.setFileLength(String.valueOf(file.length()));\n            ossFileRecord.setVisitCount(1);\n            ossFileRecord.setRemarks(\"OssFileRecord\");\n        }\n        ossFileRecordService.insertOrUpdate(ossFileRecord);\n    }\n\n    /**\n     * 文件支持分块下载和断点续传\n     * @param filePath 文件完整路径\n     * @param request 请求\n     * @param response 响应\n     */\n    private void fileChunkDownload(String filePath, HttpServletRequest request, HttpServletResponse response) {\n        String range = request.getHeader(\"Range\");\n        LOGGER.info(\"current request rang:\" + range);\n        File file = new File(filePath);\n        //开始下载位置\n        long startByte = 0;\n        //结束下载位置\n        long endByte = file.length() - 1;\n        LOGGER.info(\"文件开始位置：{}，文件结束位置：{}，文件总长度：{}\", startByte, endByte, file.length());\n\n        //有range的话\n        if (range != null \u0026amp;\u0026amp; range.contains(\"bytes=\") \u0026amp;\u0026amp; range.contains(\"-\")) {\n            range = range.substring(range.lastIndexOf(\"=\") + 1).trim();\n            String[] ranges = range.split(\"-\");\n            try {\n                //判断range的类型\n                if (ranges.length == 1) {\n                    //类型一：bytes=-2343\n                    if (range.startsWith(\"-\")) {\n                        endByte = Long.parseLong(ranges[0]);\n                    }\n                    //类型二：bytes=2343-\n                    else if (range.endsWith(\"-\")) {\n                        startByte = Long.parseLong(ranges[0]);\n                    }\n                }\n                //类型三：bytes=22-2343\n                else if (ranges.length == 2) {\n                    startByte = Long.parseLong(ranges[0]);\n                    endByte = Long.parseLong(ranges[1]);\n                }\n\n            } catch (NumberFormatException e) {\n                startByte = 0;\n                endByte = file.length() - 1;\n                LOGGER.error(\"Range Occur Error,Message:{}\",e.getLocalizedMessage());\n            }\n        }\n\n        //要下载的长度\n        long contentLength = endByte - startByte + 1;\n        //文件名\n        String fileName = file.getName();\n        //文件类型\n        String contentType = request.getServletContext().getMimeType(fileName);\n\n        ////解决下载文件时文件名乱码问题\n        byte[] fileNameBytes = fileName.getBytes(StandardCharsets.UTF_8);\n        fileName = new String(fileNameBytes, 0, fileNameBytes.length, StandardCharsets.ISO_8859_1);\n\n        //各种响应头设置     \n        //支持断点续传，获取部分字节内容：\n        response.setHeader(\"Accept-Ranges\", \"bytes\");\n        //http状态码要为206：表示获取部分内容\n        response.setStatus(HttpServletResponse.SC_PARTIAL_CONTENT);\n        response.setContentType(contentType);\n        response.setHeader(\"Content-Type\", contentType);\n        //inline表示浏览器直接使用，attachment表示下载，fileName表示下载的文件名\n        response.setHeader(\"Content-Disposition\", \"inline;filename=\" + fileName);\n        response.setHeader(\"Content-Length\", String.valueOf(contentLength));       \n        // Content-Range，格式为：[要下载的开始位置]-[结束位置]/[文件总大小]\n        response.setHeader(\"Content-Range\", \"bytes \" + startByte + \"-\" + endByte + \"/\" + file.length());\n\n        BufferedOutputStream outputStream = null;\n        RandomAccessFile randomAccessFile = null;\n        //已传送数据大小\n        long transmitted = 0;\n        try {\n            randomAccessFile = new RandomAccessFile(file, \"r\");\n            outputStream = new BufferedOutputStream(response.getOutputStream());\n            byte[] buff = new byte[4096];\n            int len = 0;\n            randomAccessFile.seek(startByte);\n            //坑爹地方四：判断是否到了最后不足4096（buff的length）个byte这个逻辑（(transmitted + len) \u0026lt;= contentLength）要放前面！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！\n            //不然会会先读取randomAccessFile，造成后面读取位置出错，找了一天才发现问题所在\n            while ((transmitted + len) \u0026lt;= contentLength \u0026amp;\u0026amp; (len = randomAccessFile.read(buff)) != -1) {\n                outputStream.write(buff, 0, len);\n                transmitted += len;\n            }\n            //处理不足buff.length部分\n            if (transmitted \u0026lt; contentLength) {\n                len = randomAccessFile.read(buff, 0, (int) (contentLength - transmitted));\n                outputStream.write(buff, 0, len);\n                transmitted += len;\n            }\n\n            outputStream.flush();\n            response.flushBuffer();\n            randomAccessFile.close();\n           LOGGER.info(\"下载完毕：\" + startByte + \"-\" + endByte + \"：\" + transmitted);\n        } catch (ClientAbortException e) {\n            LOGGER.warn(\"用户停止下载：\" + startByte + \"-\" + endByte + \"：\" + transmitted);\n            //捕获此异常表示拥护停止下载\n        } catch (IOException e) {\n            e.printStackTrace();\n            LOGGER.error(\"用户下载IO异常，Message：{}\", e.getLocalizedMessage());\n        } finally {\n            try {\n                if (randomAccessFile != null) {\n                    randomAccessFile.close();\n                }\n            } catch (IOException e) {\n                e.printStackTrace();\n            }\n        }///end try\n    }\n\n }\n\u003c/code\u003e\u003c/pre\u003e\n\u003cblockquote\u003e\n\u003cp\u003eps：需要注意的几个方面:\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003eHttp状态码为206，表示获取部分内容；\u003c/li\u003e\n\u003cli\u003eContent-Range，格式为[要下载的开始位置]-[结束位置]/[文件总大小]；\u003c/li\u003e\n\u003cli\u003eAccept-Ranges 设置为bytes；\u003cbr\u003e\n可以参考：\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://links.jianshu.com/go?to=https%3A%2F%2Fwww.ibm.com%2Fdeveloperworks%2Fcn%2Fjava%2Fjoy-down%2Findex.html\" target=\"_blank\"\u003e用 Java 实现断点续传 (HTTP)\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://links.jianshu.com/go?to=https%3A%2F%2Fwww.iteye.com%2Fblog%2Fhw1287789687-2188500\" target=\"_blank\"\u003eContent-disposition中Attachment和inline的区别\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://links.jianshu.com/go?to=https%3A%2F%2Fdeveloper.mozilla.org%2Fzh-CN%2Fdocs%2FWeb%2FHTTP%2FHeaders%2FContent-Disposition\" target=\"_blank\"\u003eHTTP headers\u003c/a\u003e\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/blockquote\u003e\n\u003ch3\u003e三、前面Html页面\u003c/h3\u003e\n\u003cpre\u003e\u003ccode\u003e\u0026lt;!DOCTYPE html\u0026gt;\n\u0026lt;html lang=\"en\"\u0026gt;\n\u0026lt;head\u0026gt;\n    \u0026lt;meta charset=\"UTF-8\"\u0026gt;\n    \u0026lt;title\u0026gt;操作视频\u0026lt;/title\u0026gt;\n\u0026lt;/head\u0026gt;\n\u0026lt;body\u0026gt;\n\u0026lt;div style=\"text-align: center; margin-top: 50px; \"\u0026gt;\n\n    \u0026lt;h2\u0026gt;操作视频\u0026lt;/h2\u0026gt;\n    \u0026lt;video width=\"75%\" height=600\" controls=\"controls\" controlslist=\"nodownload\"\u0026gt;\n        \u0026lt;source id=\"my_video_1\" src=\"http://localhost:9070/api/v1/resource/file/video/small.mp4\" type=\"video/ogg\"/\u0026gt;\n        \u0026lt;source id=\"my_video_2\" src=\"http://localhost:9070/api/v1/resource/file/video/small.mp4\" type=\"video/mp4\"/\u0026gt;\n        Your browser does not support the video tag.\n    \u0026lt;/video\u0026gt;\n   \n   \u0026lt;h2 style=\"color: red;\"\u0026gt;该操作视频不存在或已经失效.\u0026lt;/h2\u0026gt;\n \n\u0026lt;/div\u0026gt;\n\u0026lt;/body\u0026gt;\n\u0026lt;/html\u0026gt;\n\u003c/code\u003e\u003c/pre\u003e\n\u003ch3\u003e四、缓存文件定时删除任务\u003c/h3\u003e\n\u003cpre\u003e\u003ccode\u003epackage com.unnet.yjs.config;\n\nimport com.unnet.yjs.base.ContainerProperties;\nimport com.unnet.yjs.entity.Log;\nimport com.unnet.yjs.entity.OssFileRecord;\nimport com.unnet.yjs.service.OssFileRecordService;\nimport org.slf4j.Logger;\nimport org.slf4j.LoggerFactory;\nimport org.springframework.context.annotation.Configuration;\nimport org.springframework.scheduling.annotation.EnableScheduling;\nimport org.springframework.scheduling.annotation.Scheduled;\nimport org.springframework.stereotype.Component;\n\nimport javax.annotation.Resource;\nimport java.io.File;\nimport java.text.DecimalFormat;\nimport java.util.ArrayList;\nimport java.util.List;\n\n/**\n * Email: love1208tt@foxmail.com\n * Copyright (c)  2019. missbe\n * @author lyg   19-7-10 下午7:48\n *\n *\n **/\n@Component\n@Configuration\n@EnableScheduling\npublic class ScheduleTaskConfig {\n    private static final Logger LOGGER = LoggerFactory.getLogger(ScheduleTaskConfig.class);\n    @Resource\n    private ContainerProperties containerProperties;\n    @Resource\n    private OssFileRecordService ossFileRecordService;\n\n    @Scheduled(cron =  \"0 0 2 1/7 * ?\")\n//    @Scheduled(cron =  \"0/40 * * * * ?\")\n    private void scheduleDeleteFile(){\n        Log sysLog = new Log();\n        sysLog.setBrowser(\"Default\");\n        sysLog.setUsername(\"OssFileTask\");\n        sysLog.setType(\"OssFileTask\");\n        sysLog.setTitle(\"OssFileTask\");\n        long startTime = System.currentTimeMillis();\n        LOGGER.info(\"开始定时删除缓存文件任务，控制文件夹【{}】大小.\",containerProperties.getFileCacheLocation());\n        long folderSize = getFolderSize();\n        long gUnit = 1073741824L;\n        String restrictSizeString = containerProperties.getRestrictSize();\n        long restrictSize = Long.parseLong(restrictSizeString);\n        LOGGER.info(\"文件夹：【{}】，大小：【{}】，限制大小为：【{}G】\",containerProperties.getFileCacheLocation(),formatFileSize(folderSize),restrictSize);\n        ///如果超出限制进行清理\n        restrictSize = restrictSize * gUnit;\n        if ( restrictSize \u0026lt; folderSize) {\n            List\u0026lt;OssFileRecord\u0026gt; ossFileRecords = ossFileRecordService.findAll();\n            List\u0026lt;OssFileRecord\u0026gt; waitDeleteRecord = new ArrayList\u0026lt;\u0026gt;();\n            ////删除限制大小的一半内容\n            restrictSize = restrictSize / 2;\n            long totalWaitDeleteSize = 0L;\n            for (OssFileRecord record : ossFileRecords) {\n                if (totalWaitDeleteSize \u0026lt; restrictSize) {\n                    waitDeleteRecord.add(record);\n                    totalWaitDeleteSize += Long.parseLong(record.getFileLength());\n                }else {\n                    break;\n                }///end if\n            }///end for\n            File waitDeleteFile;\n            StringBuilder builder = new StringBuilder();\n            for (OssFileRecord record : waitDeleteRecord) {\n                waitDeleteFile = new File(containerProperties.getFileCacheLocation() + record.getFileName());\n                boolean isDelete = waitDeleteFile.delete();\n                if (isDelete) {\n                    LOGGER.info(\"文件【{}】删除成功.\",record);\n                    ///删除该条记录\n                    record.deleteById();\n                }else{\n                    builder.append(record);\n                    LOGGER.info(\"文件【{}】删除失败.\",record);\n                }///end if\n            }\n            sysLog.setException(builder.toString());\n            LOGGER.info(\"结束定时删除缓存文件任务，此次删除【{}】文件.文件夹剩余大小：{}\",formatFileSize(totalWaitDeleteSize),formatFileSize(getFolderSize()));\n        }else {\n            LOGGER.info(\"结束定时删除缓存文件任务，文件夹【{}】未超过限定大小.\",containerProperties.getFileCacheLocation());\n        }\n        sysLog.setUseTime(System.currentTimeMillis() - startTime);\n        sysLog.setRemoteAddr(\"127.0.0.1\");\n        sysLog.setRequestUri(\"/api/v1/resource/file/video\");\n        sysLog.setClassMethod(this.getClass().getName());\n        sysLog.setHttpMethod(\"Native\");\n        ///add sys log\n        sysLog.insert();\n    }\n    private long getFolderSize(){\n        String folderPath = containerProperties.getFileCacheLocation();\n        File parentDir = new File(folderPath);\n        if (!parentDir.exists()) {\n            boolean isMakeParentDir = parentDir.mkdirs();\n            if(isMakeParentDir){\n                LOGGER.info(\"创建文件夹{}成功.\",parentDir.getAbsolutePath());\n            }else {\n                LOGGER.error(\"创建文件夹{}失败.\",parentDir.getAbsolutePath());\n            }\n        }//end if\n        return getFileSize(parentDir);\n    }\n\n    /**\n     * 递归计算文件夹或文件占用大小\n     * @param file 文件\n     * @return 文件总大小\n     */\n    private long getFileSize(File file){\n        if (file.isFile()) {\n            return file.length();\n        }\n        long totalSize = 0;\n        File[] listFiles = file.listFiles();\n        assert listFiles != null;\n        for (File f : listFiles) {\n            if (f.isDirectory()) {\n                totalSize += getFileSize(f);\n            }else{\n                totalSize += f.length();\n            }\n        }///end for\n        return totalSize;\n    }\n    private  String formatFileSize(long fileByte) {\n        DecimalFormat df = new DecimalFormat(\"#.00\");\n        String fileSizeFormat = \"\";\n        if (fileByte \u0026lt; 1024) {\n            fileSizeFormat = df.format((double) fileByte) + \"B\";\n        } else if (fileByte \u0026lt; 1048576) {\n            fileSizeFormat = df.format((double) fileByte / 1024) + \"K\";\n        } else if (fileByte \u0026lt; 1073741824) {\n            fileSizeFormat = df.format((double) fileByte / 1048576) + \"M\";\n        } else {\n            fileSizeFormat = df.format((double) fileByte / 1073741824) + \"G\";\n        }\n        return fileSizeFormat;\n    }\n\n}\n\u003c/code\u003e\u003c/pre\u003e\n\u003cblockquote\u003e\n\u003cp\u003eps:文件缓存在本地，设置缓存上界，当达到了阈值时进行删除文件操作，文件删除根据访问次数，每次文件访问记录访问历史，根据访问历史来进行清除；其它配置字段如下：\u003c/p\u003e\n\u003c/blockquote\u003e\n\u003cpre\u003e\u003ccode\u003e###配置本地文件缓存位置-以/结尾【对象存储才会缓存到本地】\nok.resource.file.cache.location=/data/oneclick/video/\n\n###配置本地视频缓存文件大小，默认5G；超过大小根据访问次数进行清理\nok.resource.file.cache.restricted.size=5\n\u003c/code\u003e\u003c/pre\u003e\n\u003ch3\u003e五、功能实现图\u003c/h3\u003e\n\u003cdiv class=\"image-package\"\u003e\n\u003cdiv class=\"image-container\" style=\"max-width: 700px; max-height: 689px;\"\u003e\n\u003cdiv class=\"image-container-fill\" style=\"padding-bottom: 47.85%;\"\u003e\u003c/div\u003e\n\u003cdiv class=\"image-view\" data-width=\"1440\" data-height=\"689\"\u003e\u003cimg data-original-src=\"//upload-images.jianshu.io/upload_images/11736889-3445e784899b338a.png\" data-original-width=\"1440\" data-original-height=\"689\" data-original-format=\"image/png\" data-original-filesize=\"835334\"\u003e\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"image-caption\"\u003eimage.png\u003c/div\u003e\n\u003c/div\u003e\u003cbr\u003e\n\u003cdiv class=\"image-package\"\u003e\n\u003cdiv class=\"image-container\" style=\"max-width: 700px; max-height: 353px;\"\u003e\n\u003cdiv class=\"image-container-fill\" style=\"padding-bottom: 50.339999999999996%;\"\u003e\u003c/div\u003e\n\u003cdiv class=\"image-view\" data-width=\"1490\" data-height=\"750\"\u003e\u003cimg data-original-src=\"//upload-images.jianshu.io/upload_images/11736889-ceb3093e7f9dd45e.png\" data-original-width=\"1490\" data-original-height=\"750\" data-original-format=\"image/png\" data-original-filesize=\"1218632\"\u003e\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"image-caption\"\u003eimage.png\u003c/div\u003e\n\u003c/div\u003e\n","voted_down":false,"rewardable":true,"show_paid_comment_tips":false,"share_image_url":"https://upload-images.jianshu.io/upload_images/11736889-3445e784899b338a.png","slug":"c449dec43099","user":{"liked_by_user":false,"following_count":45,"gender":1,"slug":"1331c2256306","intro":"","likes_count":178,"nickname":"依然慢节奏","badges":[],"total_fp_amount":"31371969171143016505","wordage":27200,"avatar":"https://upload.jianshu.io/users/upload_avatars/11736889/b7c8de10-60ca-437e-81da-5ab169cdbb45","id":11736889,"liked_user":false},"likes_count":31,"paid_type":"free","show_ads":true,"paid_content_accessible":false,"total_fp_amount":"9781000000000000000","trial_open":false,"reprintable":true,"bookmarked":false,"wordage":275,"featured_comments_count":0,"downvotes_count":0,"wangxin_trial_open":false,"commentable":true,"total_rewards_count":0,"id":56640005,"notebook":{"name":""},"description":"一、功能目的 SpringBoot 实现Http分片下载断点续传，从而实现H5页面的大视频播放问题，实现渐进式播放，每次只播放需要播放的内容就可以了，不需要加载整个文件到内存...","first_shared_at":1574259420,"views_count":809,"notebook_id":38440121},"baseList":{"likeList":[],"rewardList":[]},"status":"success","statusCode":0},"user":{"isLogin":false,"userInfo":{}},"comments":{"list":[],"featuredList":[]}},"initialProps":{"pageProps":{"query":{"slug":"c449dec43099"}},"localeData":{"common":{"jianshu":"简书","diamond":"简书钻","totalAssets":"总资产{num}","diamondValue":" (约{num}元)","login":"登录","logout":"注销","register":"注册","on":"开","off":"关","follow":"关注","followBook":"关注连载","following":"已关注","cancelFollow":"取消关注","publish":"发布","wordage":"字数","audio":"音频","read":"阅读","reward":"赞赏","zan":"赞","comment":"评论","expand":"展开","prevPage":"上一页","nextPage":"下一页","floor":"楼","confirm":"确定","delete":"删除","report":"举报","fontSong":"宋体","fontBlack":"黑体","chs":"简体","cht":"繁体","jianChat":"简信","postRequest":"投稿请求","likeAndZan":"喜欢和赞","rewardAndPay":"赞赏和付费","home":"我的主页","markedNotes":"收藏的文章","likedNotes":"喜欢的文章","paidThings":"已购内容","wallet":"我的钱包","setting":"设置","feedback":"帮助与反馈","loading":"加载中...","needLogin":"请登录后进行操作","trialing":"文章正在审核中...","reprintTip":"禁止转载，如需转载请通过简信或评论联系作者。"},"error":{"rewardSelf":"无法打赏自己的文章哟~"},"message":{"paidNoteTip":"付费购买后才可以参与评论哦","CommentDisableTip":"作者关闭了评论功能","contentCanNotEmptyTip":"回复内容不能为空","addComment":"评论发布成功","deleteComment":"评论删除成功","likeComment":"评论点赞成功","setReadMode":"阅读模式设置成功","setFontType":"字体设置成功","setLocale":"显示语言设置成功","follow":"关注成功","cancelFollow":"取消关注成功","copySuccess":"复制代码成功"},"header":{"homePage":"首页","download":"下载APP","discover":"发现","message":"消息","reward":"赞赏支持","editNote":"编辑文章","writeNote":"写文章"},"note":{},"noteMeta":{"lastModified":"最后编辑于 ","wordage":"字数 {num}","viewsCount":"阅读 {num}"},"divider":{"selfText":"以下内容为付费内容，定价 ¥{price}","paidText":"已付费，可查看以下内容","notPaidText":"还有 {percent} 的精彩内容","modify":"点击修改"},"paidPanel":{"buyNote":"支付 ¥{price} 继续阅读","buyBook":"立即拿下 ¥{price}","freeTitle":"该作品为付费连载","freeText":"购买即可永久获取连载内的所有内容，包括将来更新的内容","paidTitle":"还没看够？拿下整部连载！","paidText":"永久获得连载内的所有内容, 包括将来更新的内容"},"book":{"last":"已是最后","lookCatalog":"查看连载目录","header":"文章来自以下连载"},"action":{"like":"{num}人点赞","collection":"收入专题","report":"举报文章"},"comment":{"allComments":"全部评论","featuredComments":"精彩评论","closed":"评论已关闭","close":"关闭评论","open":"打开评论","desc":"按时间倒序","asc":"按时间正序","disableText1":"用户已关闭评论，","disableText2":"与Ta简信交流","placeholder":"写下你的评论...","publish":"发表","create":" 添加新评论","reply":" 回复","restComments":"还有{num}条评论，","expandImage":"展开剩余{num}张图","deleteText":"确定要删除评论么？"},"collection":{"title":"被以下专题收入，发现更多相似内容","putToMyCollection":"收入我的专题"},"seoList":{"title":"推荐阅读","more":"更多精彩内容"},"sideList":{"title":"推荐阅读"},"wxShareModal":{"desc":"打开微信“扫一扫”，打开网页后点击屏幕右上角分享按钮"},"bookChapterModal":{"try":"试读","toggle":"切换顺序"},"collectionModal":{"title":"收入到我管理的专题","search":"搜索我管理的专题","newCollection":"新建专题","create":"创建","nothingFound":"未找到相关专题","loadMore":"展开查看更多"},"contributeModal":{"search":"搜索专题投稿","newCollection":"新建专题","addNewOne":"去新建一个","nothingFound":"未找到相关专题","loadMore":"展开查看更多","managed":"我管理的专题","recommend":"推荐专题"},"QRCodeShow":{"payTitle":"微信扫码支付","payText":"支付金额"},"rewardModal":{"title":"给作者送糖","custom":"自定义","placeholder":"给Ta留言...","choose":"选择支付方式","balance":"简书余额","tooltip":"网站该功能暂时下线，如需使用，请到简书App操作","confirm":"确认支付","success":"赞赏成功"},"payModal":{"payBook":"购买连载","payNote":"购买文章","promotion":"优惠券","promotionFetching":"优惠券获取中...","noPromotion":"无可用优惠券","promotionNum":"{num}张可用","noUsePromotion":"不使用优惠券","validPromotion":"可用优惠券","invalidPromotion":"不可用优惠券","total":"支付总额","tip1":"· 你将购买的商品为虚拟内容服务，购买后不支持退订、转让、退换，请斟酌确认。","tip2":"· 购买后可在“已购内容”中查看和使用。","success":"购买成功"},"reportModal":{"ad":"广告及垃圾信息","plagiarism":"抄袭或未授权转载","placeholder":"写下举报的详情情况（选填）","success":"举报成功"}},"currentLocale":"zh-CN","asPath":"/p/c449dec43099"}},"page":"/p/[slug]","query":{"slug":"c449dec43099"},"buildId":"fot9urNAlFIf4ImZl9xre","assetPrefix":"https://cdn2.jianshu.io/shakespeare"}</script><script nomodule="" src="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/polyfills-83c9f0eea3aa0edfd89e.js"></script><script async="" data-next-page="/p/[slug]" src="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/[slug].js"></script><script async="" data-next-page="/_app" src="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/_app.js"></script><script src="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/webpack-24455e893ca493bd6438.js" async=""></script><script src="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/commons.6f517ba4cf1108d0202d.js" async=""></script><script src="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/styles.bc441c9093dbddd27ab9.js" async=""></script><script src="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/main-516394b4705a784b7589.js" async=""></script><ins class="adsbygoogle adsbygoogle-noablate" data-adsbygoogle-status="done" style="display: none !important;"><ins id="aswift_3_expand" style="display:inline-table;border:none;height:0px;margin:0;padding:0;position:relative;visibility:visible;width:0px;background-color:transparent;"><ins id="aswift_3_anchor" style="display:block;border:none;height:0px;margin:0;padding:0;position:relative;visibility:visible;width:0px;background-color:transparent;"><iframe frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" allowfullscreen="true" onload="var i=this.id,s=window.google_iframe_oncopy,H=s&amp;&amp;s.handlers,h=H&amp;&amp;H[i],w=this.contentWindow,d;try{d=w.document}catch(e){}if(h&amp;&amp;d&amp;&amp;(!d.body||!d.body.firstChild)){if(h.call){setTimeout(h,0)}else if(h.match){try{h=s.upd(h,i)}catch(e){}w.location.replace(h)}}" id="aswift_3" name="aswift_3" style="left:0;position:absolute;top:0;border:0px;width:0px;height:0px;" src="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/saved_resource(6).html"></iframe></ins></ins></ins><iframe id="google_osd_static_frame_9138001732647" name="google_osd_static_frame" style="display: none; width: 0px; height: 0px;" src="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/saved_resource(7).html"></iframe><div><div class="_3Vh8Z9"><span></span></div></div></body><iframe id="google_esf" name="google_esf" src="SpringBoot Java实现Http方式分片下载断点续传+实现H5大视频渐进式播放 - 简书_files/zrt_lookup.html" data-ad-client="ca-pub-3077285224019295" style="display: none;"></iframe></html>